Coercebrep() not working as before

I think in older versions this worked. Is this an intentional change?

what version of Rhino?
if you add a print statement for x, are you getting a GUID or a Rhino.Geometry object?

If you are getting a Rhino.Geometry.Brep…you don’t need to coerce it.

I get GUID
Rhino 6.10.18311

can you post a file that shows the undesired results? From the screenshot you show, if you just change the type hint to BREP, it does the work for you, no need to coerce anything. But, perhaps I am missing your intended goal?

import rhinoscriptsyntax as rs

# x with no type hint and item access, returns GUID
# x with type hint set to BREP, returns Rhino.Geometry.Brep
print x

You’re right
But Ghpython used to be easier when I could call coerce() without type hint. I’m mostly whining about a feature loss. Not a problem.

I just tested it right now in a Release Candidate of SR12,

Version 6 SR12
(6.12.18325.5581, 11/21/2018)
Licenza Lab Not For Resale

it appears to work as expected. A possible reason of this not working might be the fact that some other component changes the state of scriptcontext.doc, forgetting to set it back afterwards.

If you are unsure, you can

import scriptcontext
#should print the address of a GhPython.DocReplacement.GrasshopperDocument (5.4 KB)

PS: please, always add an example file when reporting a bug, @Will_Wang . Your reports are welcome. Thank you!

1 Like