Grasshopper

algorithmic modeling for Rhino

Following this post
I could use the functions of a pluggin in rhino grasshopper components.

Only the method used does not allow me to manage one object at a time.
If there are several objects then the command is repeated as many times as object.

I wish to send by this method a list of objects.

Exemple:

Private Sub RunScript(ByVal x As Mesh, ByVal y As Mesh, ByRef A As Object) 
'Add the objects to Rhino
Dim idMeshA As Guid = doc.Objects.AddMesh(x)
Dim idMeshB As Guid = doc.Objects.AddMesh(y)
Dim runtimeEvent As UInteger = New Rhino.DocObjects.ObjRef(idMeshB).RuntimeSerialNumber

'Create the command macro
Dim command As String = "MeshBooleanDifference"
Dim macro As String = String.Format("!_-{0} _SelID ""{1}"" _Enter _SelID ""{2}"" _Enter", command, idMeshA, idMeshB)

'Run the macro
Rhino.RhinoApp.RunScript("_SelNone", False)
Rhino.RhinoApp.RunScript(macro, True)

'Harvest new meshes
Dim objs As Rhino.DocObjects.RhinoObject() = doc.Objects.AllObjectsSince(runtimeEvent)
Dim rc As New List(Of Mesh)
For Each obj As Rhino.DocObjects.RhinoObject In objs
Dim m As Mesh = Nothing
GH_Convert.ToMesh(obj.Geometry, m, GH_Conversion.Both)

If (m Is Nothing) Then Continue For
rc.Add(m.DuplicateMesh())

doc.Objects.Delete(obj.Id, True)
Next

A = rc
End Sub

Views: 1511

Replies to This Discussion

Hi David,
I will come to you on the deleting of entities rhino when running VB code.
I noticed that, if all the geometries are defined only by grasshopper, all goes well.

I think we should be able to manage the removal by iD. what do you recommend?



Thanks for your reply.

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