algorithmic modeling for Rhino
Hey everyone,
I was hoping to be able to use the createPatch method in a custom VB component like so:
Private Sub RunScript(ByVal crvs As Curve, ByRef patch As Object)
Dim brepPatch As brep
brepPatch.CreatePatch(crvs, 10, 10, .01)
patch = brepPatch
End Sub
but I get the error:
Unable to cast object of type 'Rhino.Geometry.LineCurve' to type 'System.Collections.Generic.IEnumerable'1[Rhino.Geometry.GeometryBase]'
But when I look at the Inheritance Hierarchy, I see Rhino.Geometry.LineCurve under Rhino.Geometry.GeometryBase.
I know I'm missing something - probably something simple - I'm just not sure what.
Thanks in advance for the help,
-Brian
Tags:
A couple things:
1. You have to set the crvs input to be "List Access" rather than "Item Access" - the method is looking for a List (or other IEnumerable) of GeometryBase, and instead you are passing it a single curve at a time.
2. CreatePatch is what's called a "Static" method, meaning it's called on the class rather than on an object (instance of the class). You will get an error if you try to run your code as written. Instead, the single line:
patch = Brep.CreatePatch(crvs, 10, 10, .01)
should do what you want.
Ahhh, ok great. As always, thank you very much.
Hi Brian,
You're feeding the CreatePath command a single curve, but it asks for a collection of geometry.
I think the easiest would be to write something like (note: untested)
Dim geometry As New List(OF GeometryBase)
geometry.Add(crvs) 'use AddRange if you have multiple curves...
Dim patch As Brep = Brep.CreatePatch(geometry, 10, 10, .01)
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David, I wrongly assumed the issue was that curves were somehow not part of Rhino.Geometry.GeometryBase, and missed that "collections" was the operative term here.
Any chance we could get a patch component in the next release?
Or the one after would be fine too :)
Patch is only available in Rhino5, so I cannot add one to Grasshopper until I first code up a mechanism that allows GH to distinguish between R4+R5 and R5only components. I think this is a waste of time as we're on our way to ditch R4 support entirely once R5 hits the shelves.
There's loads of new stuff in Rhino5 that would be really useful, so that'll mean a real step up for GH as well.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
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