GhPython and Breps

Hello @dale,

I’m trying to get this def to work in GH, but it doesn’t ComponentIndexType or Index for any type of geometry, despite having the correct type hints.

What am I doing wrong?

As an aside, if I have the type hint in the input set to Brep, what is the easiest way to get the GUID? I made a separate input here, but would like avoid this in the future.

Thanks,

Dan

You’re expecting us to re-type your code (and Rhino file) instead of posting it yourself.

Docs for ObjRef.GeometryComponentIndex say “The parent geometry has a component index = -1”. This is what you’re seeing and why GeometryComponentIndex.ComponentIndexType us returning InvalidType.

I haven’t used these methods before, but I believe they are intended to be used when you’re selecting sub-objects from Rhino.

If you want to access the faces, edges, or vertices of a brep why not use the properties and methods of the Rhino.Geometry.Brep class to access them?

Would be helpful if you would post your code and describe what you’re trying to accomplish.

-Kevin

No, I’m not. I just need help understanding how ObjRef can/should be used in GH.

Does this approach even make sense? Or is the another way to access ComponentIndexType and/or Index?

@kev.r

Thanks, that helps a lot.

For what it’s worth, here is the code snippet I was working on earlier today:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.DocObjects as rd
import Rhino.Geometry as rg
import System.Drawing as sd
import Rhino

doc = Rhino.RhinoDoc.ActiveDoc

objref = rd.ObjRef(doc,y)

print objref.ObjectId
print objref.GeometryComponentIndex.ComponentIndexType
print objref.GeometryComponentIndex.Index

and here is the code I’m using now, which is returning Area, Types, Indices, Loops and Faces

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.DocObjects as rd
import Rhino.Geometry as rg
import System.Drawing as sd
import Rhino


area = x.GetArea()
#pointInside = x.GetPointInside(0.01)

edges = x.Edges
faceList = x.Faces

faces  = []
loops  = []
indices =  []
types = []

for i in faceList:
    faces.append(i)

for i in faceList:
    loop = i.OuterLoop    
    loops.append(loop)
    
for i in faceList:
    index = i.FaceIndex    
    indices.append(index)
    
for i in faceList:
    type = i.ObjectType    
    types.append(type)

It is far easier to answer questions when your code and geometry is posted.

@Joseph_Oster got it. Will do.