Checking on variables when errors occur

I’m using ghpython and running into an error with my script where the index is out of range. In cases like these, I can usually print() number variables to see what is wrong. Is there any way to print a list of curves or surfaces to see if there are any irregularities in those variables? When I print a curve, the curve does not visually appear in the Rhino viewport. Is there anyway to turn something like this to visible curves?

Array[Curve]((<Rhino.Geometry.NurbsCurve object at 0x000000000000008F [Rhino.Geometry.NurbsCurve]>, <Rhino.Geometry.NurbsCurve object at 0x0000000000000090 [Rhino.Geometry.NurbsCurve]>, <Rhino.Geometry.NurbsCurve object at 0x0000000000000091 [Rhino.Geometry.NurbsCurve]>, <Rhino.Geometry.NurbsCurve object at 0x0000000000000092 [Rhino.Geometry.NurbsCurve]>, <Rhino.Geometry.NurbsCurve object at 0x0000000000000093 [Rhino.Geometry.NurbsCurve]>, <Rhino.Geometry.NurbsCurve object at 0x0000000000000094 [Rhino.Geometry.NurbsCurve]>))

I don’t want to have to “”" just before the error and do a=mycurves just to check on my variables

Hi Lawrence,

If you want to see the state of the rhinoscriptsyntax target document, you can add an output variable and assign it to ‘ghdoc’. Like this (within a component with an output called ‘a’):

a = ghdoc

Of course, only rhinoscriptsyntax objects are visible.

I know it’s not much, but I hope it’s better than nothing. :slight_smile:


Not exactly. I don’t want to have to use my “a” output or create a “b” or “c” output in order to see my variable. I don’t like having to assign and reassign variables to the outputs just to see what they look like. I can plant a print() in my code to see the value of numbers, is there anyway to print curves and surfaces? They show up in the “out” output, but as the text in my original post instead of something physical that can be seen in the Rhino viewport. Is there a way to have a second ghpython component interpret the contents of “out”?

In theory, if you parse the content of the printed strings for any Guid, then you could show them in a second component. Maybe something like a regex could help. You can use an existing one as an example.

A match of [0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12} should suffice.

This will work if you are using rhinoscriptsyntax. If you only have RhinoCommon geometry, there is no way to go back to a real object from a string, sorry.