Transferring geometry within class between Python components

I’ve stumbled across a rather perplexing issue whereby any geometry I create (using rs.Addxxx methods) as part of an object (of a class) doesn’t seem to transfer to another Python node correctly.

I have a process where one Python node creates a class, does a heap of stuff, and as part of a bigger process, creates some grasshopper geometry.

I then have another node which takes that object as an input and tried to extract the variables from that object. While this works fine for most variables, it doesn’t seem to work for grasshopper geometry. I’ve recreated the type of issue in a smaller process below. Note that when I un-comment line 13 of the second node, an exception is raised:

Any ideas? For now my work around is to instead supply the variables which build the geometry in the first place and then rebuild it in the second node, however this is far from ideal

Python Extract Geometry From (6.0 KB)

Which version of Rhino are you using?
I’m on 7.9.21207.13001 and your .gh works fine without any error.
Surprisingly, the class is passing from one python component to the other correctly.

Version 6 SR34
(6.34.21034.7001, 02/03/2021)

I have rhino 6.33.20343.16431

this is working but no idea why.

Put the class constructor also on the other component, and a second object “, int” was needed in the constructor.
No idea on what’s going on… this is like my 4th time using python… :sweat_smile: :rofl: :joy:

That works because you’re just recreating the line in the second node, and ignoring what comes in from the first node. Your output at b is the new line, not the line which came in from the first node (from foo)

Try to implement RhinoCommon directly (i.e. Rhino.Geometry.Line). The whole rhinoscriptsyntax GUID hoopla is likely to cause all sorts of unexpected behaviour when you make them class properties and send these through wires.

1 Like

OK, will give that a go, thanks. I find RhinoCommon more difficult to implement as it is so much larger than rhinoscriptsyntax. Can you help find a few other equivalent commands? I need one for rs.AddPlanarSurface.


You can get the source code of a rhinoscriptsyntax function to see which RhinoCommon code it wraps like so:

1 Like

This is what you want for planar surface btw

Thanks, but that’s the wrong command - that one builds a rectangular surface on a plane by taking a plane and X & Y extents. rs.AddPlanarSurface creates a planar surface by defining planar curves. The equivalent RhinoCommon command is Rhino.Geometry.Brep.CreatePlanarBreps() - Brep.CreatePlanarBreps Method (Curve, Double)

1 Like