Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all 8557 articles
Browse latest View live

Custom grip object deleted

$
0
0

@Alberto wrote:

Hi,
Is there any way we can understand if a custom grip was deleted? I tried with CustomGripObject.OnDeleteFromDocument but it is not fired when the object is deleted. Is there some other way that I do not see? I have noticed that in the C++ SDK there is a method that notifies the grip container object that some objects were deleted.

Any help would be appreciated. Thanks a lot,
Alberto

Posts: 1

Participants: 1

Read full topic


Get custom grip from selection

$
0
0

@Alberto wrote:

Hi,
I am trying to use a get object to get the custom grips that I created. I am able to retrieve the grips but these are of type GripObject and not of my custom type. It seems like I cannot cast those to my specific type. Is there a way to do this or shall I work it around?

Alberto

Posts: 1

Participants: 1

Read full topic

Objects order

$
0
0

@ricardo.eira wrote:

There is any way to change the order of objs?

Ex:
If I have 10 obj, and select all once, and create a forearch to delete one at a time, the order
is by default that order that was drawn.

I need to change the order at my convenience, there is any comand python or c#?

Basically i need to create a list and set an order by the nearest object and so on.

Thanks

Posts: 4

Participants: 3

Read full topic

Launching Rhino 5 with a batch file and running c# scripts

$
0
0

@gustavo.uzcategui wrote:

Hi,

I am interested in running Rhino 5 remotely using a batch file. Here’s what I need to do with one batch file:

  • Launch Rhino 5
  • Run a c# script (the command “RunScript”)
  • Exit Rhino

The c# script makes a new text file. I can work out how to run Rhino via a batch file, but not run the script.

I trying to use the “/runscript” command, but I get an error “The system cannot find the file specified”

This code works good:

           ProcessStartInfo start = new ProcessStartInfo();
            
            start.FileName = "C:\\Program Files\\Rhinoceros 5 (64-bit)\\System\\Rhino.exe";
            start.WindowStyle = ProcessWindowStyle.Hidden;
            start.CreateNoWindow = true;
            start.UseShellExecute = false;
            int exitCode;

            try
            {
                using (Process proc = Process.Start(start))
                {
                    proc.WaitForExit();
                    exitCode = proc.ExitCode;
                }
            }

but if I add then “/runscript” command, get the error “The system cannot find the file specified”

           start.FileName = "C:\\Program Files\\Rhinoceros 5 (64-bit)\\System\\Rhino.exe /runscript=\"TestWriteFile\"";

Thanks very much, if you need any specifics let me know.

Posts: 1

Participants: 1

Read full topic

Drag and drop on blocks

$
0
0

@dsw wrote:

Hi

i’m currently working on drag and drop functionality in Rhino 5 and 6.
Now i encountered a problem in Rhino 6 which does not exist in Rhino 5.
The drop on object does not work correctly if i want to drop on more than one blocks. To reproduce this behaviour put two or more blocks in a scene, try to drop a material on one block and then on the other. In Rhino 5 it’s possible, in Rhino 6 not.

Any hints about that?
Thanks

Posts: 1

Participants: 1

Read full topic

Rerun command with same arguments

$
0
0

@d.hillege wrote:

Hi all,

I’m new to writing plugins in C# for Rhino, At the moment I have a functioning script/command which works quite nicely. However, my goal is that whenever the object modifies on which I "called " the command, the command reruns with the same arguments. I tried using the event handler BeforeObjectTransform. Then I found out I was thinking like a fool and now i’m using the ReplaceRhinoObject handler.

What is a good way to call my command or the class that is called from the command class again with the same arguments, e.g. selected geometry, true false values and a double.

Many thanks in advance!

Posts: 2

Participants: 2

Read full topic

ABB Plane to Euler angles

$
0
0

@Petras_Vestartas wrote:

Hi,

I have issue which is probably already solved for Euler angles for ABB.
I am trying to find convert Plane orientation to 3 numbers of Euler angles.

Does this method would help anyhow to do this?
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Transform_GetEulerZYZ.htm

I was thinking to transform XY plane to target plane and converting the transformation matrix to Euler angles.

Is this a correct way of doing this ?

Posts: 1

Participants: 1

Read full topic

4 corners of word screen viewporte

$
0
0

@ricardo.eira wrote:

There is any way to get the coordinates of the 4 corners of the active viewport?

Of course the coordinates are currently zoomed.

Word

Thanks

Posts: 3

Participants: 2

Read full topic


Layer Table update?

$
0
0

@richard_schaffranek wrote:

I have two functions.

  1. generates a Layer if it is not already in the Layer list:
Code
    public static Layer getLayer(string _layerName, System.Drawing.Color C)
    {
        Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc;
        Layer _Layer = doc.Layers.FindName(_layerName);
        if (_Layer == null)
        {
            _Layer = new Layer();
            _Layer.Name = _layerName;
            _Layer.Color = C;
            doc.Layers.Add(_Layer);
        }
        else
        {
            Layer[\*] children = _Layer.GetChildren();
            if (children != null)
            {
                foreach (Layer L in children)
                {
                    PPMStatic.clearLayer(L);
                    doc.Layers.Delete(L.Index, true);
                }
            }
        }
        doc.Layers.SetCurrentLayerIndex(_Layer.Index, true);
        return _Layer;
    }
  1. bakes blocks on individual layers and uses the layer created with the first function as parent layer:
Code

public static Guid bakeObject(GeometryBase geom, Plane planes, String Name, Layer parent = null)
{
Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc;
// delet old block definition…
string blockName = Name;
InstanceDefinition blockDef = doc.InstanceDefinitions.Find(blockName);
int blockID = -1;
if (blockDef != null)
{
doc.InstanceDefinitions.Delete(blockDef.Index, true, true);
}
ObjectAttributes _Att = PPMStatic.getObjectAttributes(Name, System.Drawing.Color.White);
if (parent != null)
{
parent = doc.Layers.FindName(parent.Name);
Layer child = doc.Layers[_Att.LayerIndex];
child.ParentLayerId = parent.Id;
child.Color = parent.Color;
}
_Att.ColorSource = ObjectColorSource.ColorFromParent;
_Att.MaterialSource = ObjectMaterialSource.MaterialFromParent;
ObjectAttributes blockAtt = new ObjectAttributes[geom.Length];
List _G = new List();
for (int i = 0; i < geom.Length; i++)
{
blockAtt[i] = _Att;
}
blockID = doc.InstanceDefinitions.Add(blockName, “PPM_autogenerated”, new Point3d(0, 0, 0), geom, blockAtt);
foreach (Plane p in planes)
{
_G.Add(doc.Objects.AddInstanceObject(blockID, Transform.PlaneToPlane(Plane.WorldXY, p)));
}
return _G.ToArray();
}

this doesn’t work for the first time, as soon as the parent layers are within the Layer list it works. As a work arround I have added the following line to kind of reget the parent layer in the second function.

parent = doc.Layers.FindName(parent.Name);

This is for Rhino 6 …

Posts: 1

Participants: 1

Read full topic

Invisible mesh edges

Explanation for ONX_Model api

$
0
0

@sghosh wrote:

Hi All,

I am trying extract components by name from an ONX_Modelusing their name

       ONX_Model model;
       model.ComponentFromName(ON_ModelComponent::Type::ModelGeometry, component_parent_id, L"some_name");

It is not clear to me how I could get the component_parent_id, could someone please point me in the right direction.

Thanks
Sunayana

Posts: 2

Participants: 2

Read full topic

Is there a SelectedLayer event?

$
0
0

@marcsyp wrote:

Hi all –

Does anyone know if there is an event handler that fires when the selection changes in the Rhino layer manager? It does not fire with “LayerTableEvent” and I’ve dug around in Rhino.UI and haven’t found anything.

I can get to the currently selected layers via the LayerTable.GetSelected() method, but I’d like to be able to grab the currently selected layer(s) in real time and I can’t find an Event that will let me do that. Even if there is a generic UI event that triggers when the panel is manipulated, I can selectively expire a downstream output by checking the currently selected layers against a cached list.

Thanks,
Marc

Posts: 7

Participants: 2

Read full topic

RhinCommon ChangeLog Rhino 5.0 - Rhino 6.0

$
0
0

@richard_schaffranek wrote:

Dear McNeal,

I am currently working on upgrading a plugin from Rhino 5.0 to Rhino 6.0 which is a bit of a pain in the ass since there is no changelog for the API (or am I missing something… ).

Just to illustrate:

I spend about 3h looking for the error when unrolling a surface:

In Rhino 5 this code worked fine:

        Unroller unroll = new Unroller(Inspiral3d.getSurface); 
        unroll.AddFollowingGeometry(Inspiral3d.getRail);
        unroll.AddFollowingGeometry(Inspiral3d.getGuideLinesCurve);

        Curve[] _C2D;
        Point3d[] _P2D;
        TextDot[] _TD2D;
        Brep[] _S2D = unroll.PerformUnroll(out _C2D,out _P2D,out _TD2D);

        this.Rail = _C2D[0].ToNurbsCurve();

Now in Rhino 6 I have to do the same thing this:

        Unroller unroll = new Unroller(Inspiral3d.getSurface); 
        unroll.AddFollowingGeometry(Inspiral3d.getGuideLinesCurve);
        unroll.AddFollowingGeometry(Inspiral3d.getRail);
       
        Curve[] _C2D;
        Point3d[] _P2D;
        TextDot[] _TD2D;
        Brep[] _S2D = unroll.PerformUnroll(out _C2D,out _P2D,out _TD2D);

        this.Rail = _C2D[0].ToNurbsCurve();

Noticed the difference?

Since the function AddFollowingGeometry is a bit of a blackbox, my guess is that in Rhino 5 it added the curves at the end of the list, now it adds it at the beginning of the list.

Is there any chance a ChangeLog for the API is released, and yes I know there is Unroller.FollowingGeometryIndex but come on a stable sorting would be expected…

Posts: 3

Participants: 2

Read full topic

3dm Password

$
0
0

@ricardo.eira wrote:

If I’m not mistaken and from what I read here in the forum, there is no method of blocking a 3dm file by password,

Ok, I need to lock a file, so I thought of a method to do it, (I just need to block a file when using my plugin)

The principle is very basic:

1ºCreate a SetDocumentData “password” with the “password chosen”
2º On “RhinoDoc.EndOpenDocument” check the SetDocumentData “password”
if password match then open document, if not match close document

Although it is a very corny method, it works and does not let open any document that has password.

I make some testes, and the problem is open by the spash screen on rhino startup, it seems to me that when opened here events “RhinoDoc.EndOpenDocument” are ignored.

or something is escaping here.

Any idea?

Posts: 5

Participants: 4

Read full topic

Contour curves on trimmed faces

$
0
0

@o11225669 wrote:

Hello,
I’m trying to retrieve the contour curves of a polysurface by calling CreateContourCurves on each face (brep.Face[i].ToBrep()).

Everything works fine but I noticed that the resulting curves are from the untrimmed face.

How can I get the trimmed face? I can see that the original brep has several BrepTrims that points to each face (via faceindex).

Posts: 2

Participants: 2

Read full topic


How does Rhino find mtl file for .OBJ file?

$
0
0

@Terry_Chappell wrote:

@pascal, @tim,

I wrote a Python script to import a .OBJ file for a mesh. It parses the .OBJ file and creates vertices, faces and vertex colors and vertex textures for the mesh. The script skips the mtllib and usemtl lines near the top of the file. After the import is complete, I switch to rendered mode and all the texture is properly displayed.

My Question: How in the world did Rhino manage to find the .mtl and the JPG texture files for this mesh??

I have been using Rhino’s Import tool up until now for my .OBJ files and that has been working fine. I just wanted to see if I could create a faster importer for the .OBJ files. I recently did this for .XYZRGB point cloud files and got a 15X speedup over Rhino’s Import tool. So I thought I would try this same approach for .OBJ files to see how much speedup is possible. I can already see from the early timings that a 2X speedup may be possible but not 15X. Apparently Rhino’s point cloud importer has been worked on a lot less than the .OBJ file importer.

The .OBJ file import was done in a new Rhino session. I did use another Rhino session to time Rhino’s Import tool to import the same mesh. Do the Rhino sessions talk to each other with respect to what .mtl file and PNG files for textures are active? Is this how the new Rhino session with the Python script was able to access these files? At some point I will restart my computer and see if the first Rhino session can find these files. But perhaps you know already?

Regards,
Terry.

Posts: 2

Participants: 2

Read full topic

Grasshoppoer Component dev using Serial port

$
0
0

@abide.nm wrote:

I have been developing my own GH component recently.
I want to make it to transmit data which received by serial port continuously, but SolveInstance( ) and component run only once so the data transmission is executed once.
Is it appropriate method that I can use? How to make the component with Serial Port?

Posts: 1

Participants: 1

Read full topic

How to use vb.net to control the display checkbox?

Migrating plugin's license system to RH6

$
0
0

@Matthieu_from_NAVINN wrote:

Hi,
I’m migrating a plugin to RH6 and I can’t figure how to adapt my RH5 license system.

In rhino5 I was doing this, which worked nicely:

Dim validator As New Rhino.PlugIns.ValidateProductKeyDelegate(AddressOf ValidateProductKey)
Dim rc As Boolean = GetLicense(Rhino.PlugIns.LicenseBuildType.Release, validator)

But I dont get how to do the exact same thing with Rhino6 (I don’t need CloudZoo). I understood that I had to create a OnLeaseChangedDelegate but when rhino starts it only display an empty license windows, with no field for serial number.
Here is my code:

' Ask Rhino to get a product license.
      Dim validator As New Rhino.PlugIns.ValidateProductKeyDelegate(AddressOf ValidateProductKey)
      Dim LeaseChanged As New Rhino.PlugIns.OnLeaseChangedDelegate(AddressOf OnLeaseChanged)
      Dim rc As Boolean = GetLicense(Rhino.PlugIns.LicenseBuildType.Release, validator, LeaseChanged)
      If Not rc Then
           Return Rhino.PlugIns.LoadReturnCode.ErrorNoDialog
      End If

      Private Sub OnLeaseChanged(ByVal args As LicenseLeaseChangedEventArgs, <Out> ByRef icon As System.Drawing.Icon)
            icon = My.Resources.BeamCalc

            'If args.Lease Is Nothing Then
            'End If
      End Sub

And this is what I get when starting rhino (It pops up several times if I try to close it):
LicenseIssue

Posts: 1

Participants: 1

Read full topic

Draw Shadows using DisplayPipeline.PostDrawObjects()

$
0
0

@Harper wrote:

Hello,

When an object is added to Document, shadows are displayed in Rendered and Raytraced Display Modes, although when it’s drawn like that:

  DisplayPipeline.PostDrawObjects += PostDrawObjects;
  private void PostDrawObjects(object sender, DrawEventArgs e)
  {
        e.Display.DrawMeshShaded(meshToDraw,displayMaterial);
        e.Display.DrawBrepShaded(brepToDraw,displayMaterial);
   }

There are no shadows, it happens using PostDraw, DrawOverlay and DrawForeground


Is there a way to enable the shadows using these methods (DrawMeshShaded and DrawBrepShaded)?

Thanks.

Posts: 1

Participants: 1

Read full topic

Viewing all 8557 articles
Browse latest View live