Grasshopper

algorithmic modeling for Rhino

Hi,

With a vb.net component, I want to select groups of curves, and then hide the curves selected and store it in a list of list of curves.

Here is my script :

Dim i,j As Integer
Dim reponse As Integer

Dim objRefs As Rhino.DocObjects.ObjRef() = Nothing
Dim lstElts As New List(Of Object)

Dim lstLstElts As New List(Of List(Of Object))

Rhino.Input.RhinoGet.GetInteger("Number of groups (max =4) ?", False, reponse, 1, 4)
For i = 0 To reponse - 1
Rhino.Input.RhinoGet.GetMultipleObjects("Select curves of group n°" & i + 1, False, Rhino.DocObjects.ObjectType.Curve, objRefs)
lstElts.Clear
For j = 0 To objRefs.Length - 1
lstElts.Add(objRefs(j).Curve())
Rhino.DocObjects.Tables.ObjectTable.Hide(objRefs(j).Curve(), True)
Next
lstLstElts.Add(lstElts)
Next

 

Everything is working, excepting hiding the curves (in Red). 

Any idea ?

Also, I would like to change the color of the curves after beeing selected, but I don't know how to do it (I used Call Rhino.ObjectColor with Rhinoscript, but I can't find the equivalence in rhinocommon).

Any idea ?

Thanks for your help

Views: 2299

Replies are closed for this discussion.

Replies to This Discussion

Before we do anything else, I think you should not be asking for user input inside a Grasshopper component. I.e. this:

Rhino.Input.RhinoGet.GetInteger(...

 

and this:

 

Rhino.Input.RhinoGet.GetMultipleObjects(...

 

Is weird. Why not use an input parameter to supply the integer?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I think what you're looking for is:

doc.Objects.Hide(objRefs(j), True)

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks,

The hide script is working now. But I still have two questions :

- About asking for user input inside a Grasshopper component, you are right, that is because I still have rhinoscript habits. BUT : I want to select multiples lines, and I don't know how to do this with the Line component because if I use "Manage line collection", I have to pick lines one by one, and I don't know how to pick a selection of lines in the Rhino window. Is it possible ? Same question for points

- How can I change the color of an existing Line with a vb script ?

Thanks for your help.

Guillaume

Set Multiple Lines in the menu will allow you to select a whole bunch at once. I don't think Grasshopper is a good tool for modifying geometry in the Rhino document though, it tends to work on its own geometry only.

Is there a reason you're unhappy with RhinoScript?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Changing display colours of Rhino objects is accomplished by modifying the attributes of the object. You'll need to get the current attributes, set the colour source and the colour, then replace the attributes.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

David,

Thanks for your answer again. I'll find out the exact script to change the color with your instructions.

I have no problem with Rhinoscript, but to me, Grasshopper is more intuitive and easier to use, so I prefer converting my old script, since I can add vb components, wich is necessary to me (I'm working on a formfinding script). Programming is not my speciality (I'm a structural engineer), so it is easer to script with visual components, rather than with 2500 lines and 15 differents arrays I would have to deal with.

But I am a bit lost with the langages I can use (vb, rhinocommon, rhinoscript,...) with vb components. Is there any document which gathers and explain this (like for exemple equivalences between Rhinoscript and rhinocommon) ?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service