Rhino 8 WIP - Python - Get Geometry From Model Object?


I have a simple python script that returns the curve degree from the input curves.

I am primarily passing geometry as “Model Objects” throughout the script.

If I use the G output of the Model Objects node and feed that into python or put a geometry type node such as “Curve” between the Model Object O output and the Python input, the script functions as expected.

I am stuck on how to, inside python, extract the geometry from a Model Object so that I don’t need an intermediary node between the Model Object and the Python script.

Please see the snip below noting that the G output of the MO node, or a Curve node after the O, solves the input needs of the python component. (I would like to skip this step and feed the O straight into python)

Graph Space:

Thanks for your help!


import rhinoscriptsyntax as rs

if C is None:
    D = C
elif rs.IsCurve(C):
    degree = rs.CurveDegree(C)
    print "Curve degree:", degree

    D = degree

One way?

Thank you @Helvetosaur , I started with the coerce method but had no luck as I need to go from Model Curve to Curve.

The Rhino 8 Model Object node handles this by giving you access to a “G” output but I’m wanting to pull the G result directly out of the Model Object as I am trying to avoid splicing in a Model Object node anytime I need to access the geometry of Model Objects.

I hope that makes sense, I’m unsure of the exact terminology or syntax to use for this.

@AndyPayne can I bother you to weigh in on this one? The short, how to pass/cast/get Model Objects as geometry in python. Thanks!