algorithmic modeling for Rhino
Hello,
I have a working vb component which accepts mesh, brep, and surface as generic data and converts it to mesh. I am certain it is not the most elegant but works...
ByVal Geometry1 As List(Of GeometryBase)
For i As Integer = 0 To Geometry1.count - 1
Dim m As New list(Of mesh)
If TypeOf Geometry1(i) Is Brep Then
Dim mes() As mesh = rhino.Geometry.Mesh.CreateFromBrep(Geometry1(i))
For n As Integer = 0 To mes.length() - 1
m.add(mes(n))
Next
End If
If TypeOf Geometry1(i) Is Mesh Then
'm = Geometry1(i)
m.add(Geometry1(i))
End If
When I use the code in a grasshopper assembly, I get the unable to cast error (.NurbsSurface, .PlaneSurface, etc..) I tried first converting the surface to Brep using the .TryConvertBrep and the .CreateFromSurface, both produced the same errors. Any thoughts?
pManager.Register_GeometryParam("Geometry 1"...
Dim Geometry1 As New List(Of GeometryBase)
If (TypeOf Geometry1(i) Is Surface) Then
Dim SrfBrp As Brep = Rhino.Geometry.Brep.TryConvertBrep(Geometry1(i))
Dim mes() As Mesh = Rhino.Geometry.Mesh.CreateFromBrep(Geometry1(i))
For n As Integer = 0 To mes.Length() - 1
m.Add(mes(n))
Next
End if
If (TypeOf Geometry1(i) Is Surface) Then
Dim SrfBrp As Brep = Rhino.Geometry.Brep.CreateFromSurface(Geometry1(i))
Dim mes() As Mesh = Rhino.Geometry.Mesh.CreateFromBrep(Geometry1(i))
For n As Integer = 0 To mes.Length() - 1
m.Add(mes(n))
Next
End If
Tags:
Well, if the Type of Geometry1(i) is Surface, then you can't call:
Dim mes() As Mesh = Rhino.Geometry.Mesh.CreateFromBrep(Geometry1(i))
you should use:
Dim SrfBrp As Brep = Rhino.Geometry.Brep.CreateFromSurface(Geometry1(i))
Dim mes() As Mesh = Rhino.Geometry.Mesh.CreateFromBrep(SrfBrp)
instead.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
D'oh!
Thanks
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by