Grasshopper

algorithmic modeling for Rhino

Hi all,

I am a scripting neophyte, so excuse the simple question. I've been looking through the .NET SDK for Rhino and I don't understand how to use most of what I see, or whether it's even still valid now that RhinoCommon has been implemented.

Anyway, I am trying to grab objects from Rhino automatically based on the layer name. This is probably elementary code for you .NET wizards out there...

Thanks,
Marc

Views: 5643

Replies to This Discussion

Almost ready to give up because I don't want you to waste time on this when you could be developing GH. :) Feel like I'm almost there though... unfortunately getting errors that the IGH_GeometricGoo and IGH_Goo types are not defined... looked around for something that might work but only found "Grasshopper.Kernel.Types.IGH_DocumentObject"... needless to say that didn't work... :( Are these Goo types custom types that aren't referenced in a standard install?

Sorry,
Marc
IGH_Goo and IGH_GeometricGoo are defined in the Grasshopper.Kernel.Types

That's what I get for writing code from the top of my head :)

--
David Rutten
david@mcneel.com
Poprad, Slovakia
I swear that I tried Grasshopper.Kernel.Types.IGH_Goo and Grasshopper.Kernel.Types.IGH_GeometricGoo yesterday with no luck, but I found them today so I must have been dreaming.

Unfortunately, while the code is clean, it's not working as expected. I'm now getting "Referenced Line-Like Curve" instead of "Line-Like Curve" in my panel but it still does not update my definition automatically when I change the Rhino geometry. It *looks* like it's going to update, in that the GH preview turns off momentarily after I change a referenced object, but it comes back on in the same state. When I hit the recalculate button in GH it updates as it should. :(

Marc
Marc,

I'll dig into this in detail. If there's a bug somewhere I'll fix it before I release the next version.

--
David Rutten
david@mcneel.com
Poprad, Slovakia

David -

 

A while back you helped me write this code that unfortunately wasn't accomplishing what we had hoped.  I've tried again in the new version and I still can't get my "Read Layer" component to update automatically when geometry is added.  You were going to look into this, way back.  Any ideas?

 

Thanks,

Marc

 

I think this discussion points out some very useful modules that would bu an amazing addition to GH. A module that has a string input (for layer names) and outputs the objects on that layer so that they can be referenced. It would of course be great if they update automatically when new objects are created on that layer. Also a module that outputs all the layer names from the document in a list would be great. It would make the handling of referenced objects much faster.
Simon... If I manage to cajole David into troubleshooting my code until it works, I'll post the component when we're done... :)

I'll give the second component a shot myself after I finish my work this week.
FYI, David, here is my code as it stands now:

Dim layer_index As Int32 = doc.Layers.Find(layer, True)
If (layer_index < 0) Then Return

Dim lay As Rhino.DocObjects.Layer = doc.Layers(layer_index)
Dim objs As Rhino.DocObjects.RhinoObject() = doc.Objects.FindByLayer(lay)
If (objs Is Nothing) Then Return

Dim layerColor As Color = lay.Color
Dim geo As New List(Of Grasshopper.Kernel.Types.IGH_Goo)

For Each obj As Rhino.DocObjects.RhinoObject In objs
Dim ref1 As New DocObjects.ObjRef(obj)
Dim goo As Grasshopper.Kernel.Types.IGH_GeometricGoo = Kernel.GH_Convert.ObjRefToGeometry(ref1)
geo.Add(goo)
Next

L = geo
col = layerColor

Are there any updates to this? I think a 'set geometry by layer' would be a great Grasshopper addition.

Great! This is what I miss most about Grasshopper.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service