I am trying to do what I thought was quite a straightforward thing to do in python: splitting a surface using either curves on it or surfaces perpendicular to it. However the splitbrep seems not to work, not accepting the perpendicular surfaces as breps, but I can’t find any other command to do it.
surfaces.3dm (84.9 KB)
Code was just
import rhinoscriptsyntax as rs
srf = rs.GetObject(“srf”, 8 )
cut = rs.GetObjects(“cutting srfs”, 8)
rs.SplitBrep(srf, cut, True)
Anyone could please help?
Set the output of rs.SplitBrep() to something, I think the result should be there. It is not an in-place operation.
Apologies, I get the error message that the surfaces could not be converted into beeps, but I don’t understand how else to split a surface then
OK, I wasn’t in front of my computer when I answered. I forgot rs.SplitBrep()
can only take one surface/polysurface as a ‘cutter’, not a collection. So when you feed it a list of surfaces from GetObjects()
, it errors out.
And, I was mistaken, it does actually split the Brep in-place, does not leave the original unsplit parts.
There is a funny workaround you can do - before running the script, select your cutting surfaces and run NonManifoldMerge
. That will convert them into a single non-manifold Brep, which will be accepted by the script. You need to change the second GetObjects
to GetObject
.
import rhinoscriptsyntax as rs
srf_id = rs.GetObject("brep to split", 8 )
cutter_id = rs.GetObject("cutting brep", 8+16)
rs.SplitBrep(srf_id, cutter_id, True)
Otherwise, it is possible to split one or more breps with a collection of other breps without NonManifoldMerge
, but for that you need a more complex script written in RhinoCommon.
1 Like
You can do this in python
import rhinoscriptsyntax as rs
def split_with_multiple_cutters(to_split, cutters):
group_name = "temp_cutters"
rs.AddGroup(group_name)
rs.AddObjectsToGroup(cutters, group_name)
rs.UnselectAllObjects()
rs.SelectObject(to_split)
rs.Command("Split -SelGroup " + group_name + " Enter")
rs.DeleteGroup(group_name)
return rs.SelectedObjects()
# testing
to_split = rs.GetObject("surface to split")
cutters = rs.GetObjects("cutters")
pieces = split_with_multiple_cutters(to_split, cutters)