Trimbrep fails in ghpy but works in py on same brep

Hi guys,
I run into a wall as the trimbrep fails in a ghpy component while it works perfectly in the regular py script editor. Want to use ghpy to compile a component. Not at the pc right now but the error of the trimbrep in ghpy was along the lines of attrib object has no id properties or something like that. Same testing brep used in both ghpy and py.
Any idea why it fails?

Hi Isvflorin
Please upload the files?

Probably because grasshopper uses its own tolerance and py the tolerance from the current document. Can you check if those 2 are the same? Had this problem also a while ago.

Thanks Jordy,
But don’t think this is the issue, I use the command witha custom tolerance argument already, as it was failing with the default in py script editor.

Ah oke. Was worth a shot :slight_smile: Got anything we can test with? The script / gh file or your failed trimbrep?

Hard to put the file in… But just tested on a blank canvas.
Create a sphere in the origin.

import rhinoscriptsyntax as rs


obj=rs.trimbrep(obj, rs.planefromnormal([0,0,0],rs.vectorcreate([0,0,0],[0,0,-1])),0.001)[0]
print obj

Do a getobject for the py version. Do you get attributedgeometry object has no attribute id?

Hi Florin, @isvflorin

What’s your setup? Especially, where are you doing the getobject()?


Giulio Piacentino
for Robert McNeel & Associates

Not all rhinoscriptsyntax functions are currently supported in ghpython components. Maybe Giulio could fix the rhobj = rhutil.coercerhinoobject(object_id) part.

In order for TrimBrep function to work, you need to switch to Rhino document.

The other solution is not to use it, but use the Brep.Trim method directly (which is what rs.TrimBrep does). (12.7 KB)
TrimBrep.3dm (37.6 KB)

1 Like

This is a bug in the originally-sound implementation of rhinoscriptsyntax. This operation should not depend from Rhino document objects - we are working on getting these calls all cleared up.

Thanks for reporting this!


Giulio Piacentino
for Robert McNeel & Associates

I was doing the getobject in the regular py script editor, the code above is for a ghpython component. Glad you guys are going to sort this out.