Grasshopper

algorithmic modeling for Rhino

Hey all,

Some help would be appreciated on this one. I've been staring at my screen and can't see where I'm going wrong, although it seems it should be an obvious answer (as they all tend to be in hindsight).

I'm trying to code  VB.NET component to use a string input (strFacadeSelector) to select all the geometry on a layer in my file. There are only surfaces on the layer in the Rhino file.

arrSurfaces is working correctly and reporting all the Rhino.DocObjects.BrepObject (*Notably on {0;0} I feel the multi-dimensional array might be my problem...)

The parameter 'Srf' is working correctly for the First Loop (i.e. arrSurfaces(0)) and returning a Trimmed Surface that I can use in Grasshopper, however there is more than one object on the layer and I cannot convert ALL the 'Rhino.Objects' to output.

I can't then seem to add all the 'Srf' parameters in my loop to a single dimensional array called 'Surfaces'.

It is returning an error (line 98 is Surfaces(k) = Srf)

Error: Value of type 'Rhino.Geometry.Brep' cannot be converted to 'System.Collections.Generic.List(Of Rhino.Geometry.Brep)'. (line 98)

Dim LayerName As String = strFacadeSelector + "fin"
Dim arrSurfaces As Rhino.DocObjects.RhinoObject() = doc.Objects.FindByLayer(LayerName)
Dim Srf As Rhino.Geometry.Brep = Nothing
Dim Surfaces() As List (Of Brep)

For k As Integer = 0 To arrSurfaces.Length - 1

Srf = arrSurfaces(k).Geometry
Surfaces(k) = Srf

Next

Any help would be appreciated.

Thanks,

/m

Views: 2480

Replies to This Discussion

Dim Surfaces() As List (Of Brep)

 

why are there brackets behind the Surfaces variable name. Are you sure they are supposed to be there?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I'd write it something like this:

Dim rhObjects As DocObjects.RhinoObject() = doc.Objects.FindByLayer(layerName)
If (rhObjects Is Nothing) Then Return

Dim breps As New List(Of Brep)
For Each rhObject As DocObjects.RhinoObject In rhObjects
  Dim brep As Brep = TryCast(rhObject.Geometry, Brep)
  If (brep IsNot Nothing) Then
    breps.Add(brep)
  End If
Next
A = breps

--

David Rutten

david@mcneel.com

Poprad, Slovakia

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