Skip to content

Commit 16f5f2f

Browse files
committed
added sanity check to prevent more than one operation at the same time
1 parent 8b677ee commit 16f5f2f

File tree

1 file changed

+9
-0
lines changed
  • src/compas_fab/ghpython/components/Cf_CollisionMesh

1 file changed

+9
-0
lines changed

src/compas_fab/ghpython/components/Cf_CollisionMesh/code.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@
1212
class CollisionMeshComponent(component):
1313
def RunScript(self, scene, M, name, add, append, remove):
1414
ok = False
15+
self.Message = ""
16+
17+
if (add and append) or (append and remove) or (add and remove):
18+
self.Message = "Use only one operation at a time\n(add, append or remove)"
19+
raise Exception(self.Message)
20+
1521
if scene and M and name:
1622
mesh = RhinoMesh.from_geometry(M).to_compas()
1723
collision_mesh = CollisionMesh(mesh, name)
1824
if add:
1925
scene.add_collision_mesh(collision_mesh)
26+
self.Message = "Added"
2027
ok = True
2128
if append:
2229
scene.append_collision_mesh(collision_mesh)
30+
self.Message = "Appended"
2331
ok = True
2432
if remove:
2533
scene.remove_collision_mesh(name)
34+
self.Message = "Removed"
2635
ok = True
2736
return ok

0 commit comments

Comments
 (0)