-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolidSplit.py
More file actions
64 lines (49 loc) · 1.54 KB
/
SolidSplit.py
File metadata and controls
64 lines (49 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import rhinoscript.userinterface
import rhinoscript.geometry
import rhinoscriptsyntax as rs
__commandname__ = "SolidSplit"
def SplitObject(solid, cSrf):
preInnerSrf = rs.CopyObject(cSrf)
innerSrfs = rs.TrimBrep(preInnerSrf, solid)
if not innerSrfs:
rs.DeleteObject(preInnerSrf)
return [solid]
solids = []
solids.append(solid)
for srf in innerSrfs:
newSolids = []
for obj in solids:
splitObjs = rs.SplitBrep(obj, srf, True)
if not splitObjs:
newSolids.append(obj)
else:
for sObj in splitObjs:
toJoin = [sObj, srf]
newSolids.append(rs.JoinSurfaces(toJoin))
rs.DeleteObjects(splitObjs)
solids = newSolids
rs.DeleteObjects(innerSrfs)
return solids
def RunCommand( is_interactive ):
filter = rs.filter.polysurface
objs = rs.GetObjects("Select solid objects to split", filter)
if not objs: return 1
solids = []
for obj in objs:
if rs.IsObjectSolid(obj):
solids.append(obj)
if len(solids) == 0:
print "No solid object found"
return 1
cSrfs = rs.GetObjects("Select cutting surfaces", filter)
if not cSrfs:
return 1
rs.EnableRedraw(False)
for srf in cSrfs:
newSolids = []
for solid in solids:
newSolids.extend(SplitObject(solid, srf))
solids = newSolids
rs.EnableRedraw(True)
return 0
RunCommand(True)