rs.getObjects in Grasshopper

If you use the battery as the input source, it works fine, but if you use code to get the object, it reports an error. What’s the problem?

You get a guid in grasshopper not a object find the object with the guid first.

I’m sorry, could you explain in detail, and could you show me how to solve this problem, thank you very much

I just want to use code to implement this feature on the image, too difficult
微信截图_20240217170739

1 Like

The contexts are muddled. The reference rs.GetObject was returned when sc.doc = Rhino.RhinoDoc.ActiveDoc. But you’re computing rs.CurveLength(obj) after sc.doc = ghdoc. Move that into a try block.

finally: still executes, even after an Exception triggers the except: (it’s not an else:). So you can get rid of the except: if all it’s doing is the same as the finally:.

It’s a good idea to bracket the arg after a print statement too, to make your code compatible with Python 3.

I seem to understand what you mean, but I am still very confused. My final goal is to load the Geometry in Rhino into GH through “rs.getobject()”, and then carry out an operation in GH (a lot of code is not pasted). My original input mode uses the Geometry battery, which works very well. If I replace it with rs.getobject(), it won’t work