Hi,
I’m trying to split an ellipsoid with another surface in the attached file. When I do the split manually in the UI, it splits fine into two pieces, whereas when I do the same using the below script, SplitBrep returns a list of two IDs, but the second ID consists of zeros and doesn’t correspond to a visible surface in the UI.
Thanks a lot for taking a look!
import rhinoscriptsyntax as rs
thintop=rs.ObjectsByName(“Thin Flower Top”)
outer2=rs.ObjectsByName(“PreFace”)
pieces=rs.SplitBrep(outer2,thintop)
badSplit.3dm (1.6 MB)
ObjectsByName returns a list of GUIDs when called. To get the individual objects in the list, you need to index the zeroth item in each variable (since there is only one object in each list). Try this:
import rhinoscriptsyntax as rs
thintop = rs.ObjectsByName("Thin Flower Top")[0]
outer2 = rs.ObjectsByName("PreFace")[0]
pieces = rs.SplitBrep(outer2, thintop, delete_input=False)
You can set delete_input to True
to delete the input brep.
Tried that, didn’t help.
The snippet I posted resulted in a list with two object IDs, one referring
to the top half of the split ellipsoid, and the other full of zeros - and
the bottom half of the split ellipsoid was missing in the UI.
After running your code, it returns a list of 4 items, of which one is
still the top half of the split ellipsoid, and the other 3 are tiny
singular surfaces near its edge - and the bottom half is still missing.
Should be trivial to reproduce, as I attached the 3dm file to the original
post.
Thanks again,
E.
Tried that, didn’t help.
The snippet I posted results in a list with two object IDs, one referring to the top half of the split ellipsoid, and the other full of zeros - and the bottom half of the split ellipsoid is missing in the UI, so I would say the split is not done correctly.
After running your code, it returns a list of 4 items, of which one is still the top half of the split ellipsoid, and the other 3 are tiny singular surfaces near its edge - and the bottom half is still missing. Should be trivial to reproduce, as I attached the 3dm file to the original post.
Thanks again,
E.
I think the issue might be the pointy things intersecting the bottom of the ellipsoid. The SplitBrep command runs similar to the BooleanSplit command (it uses the RhinoCommon method Brep.Split(Brep, Double)
). You can either get rid of the pointy things to resolve the intersection, or you can replace the last line in my script with these lines:
rs.Command("_Split SelID {0} _Enter SelID {1} _Enter".format(outer2, thintop), False)
pieces = rs.ObjectsByName("PreFace")
This calls the Rhino command Split and just runs that operation in script. The split surfaces will still be called “PreFace” and will be stored in the pieces list.
Nice syntax for referring to objects inside macros - thanks!
1 Like