aboutsummaryrefslogtreecommitdiff
path: root/Boxer.py
diff options
context:
space:
mode:
Diffstat (limited to 'Boxer.py')
-rw-r--r--Boxer.py60
1 files changed, 46 insertions, 14 deletions
diff --git a/Boxer.py b/Boxer.py
index 164aaff..0385060 100644
--- a/Boxer.py
+++ b/Boxer.py
@@ -296,22 +296,54 @@ def makeExtrudes(doc, cfg):
objects['bottom'] = makeExtrude(doc, cfg, "Bottom", doc.Bottom)
return objects
+def makeCrossSections(doc, cfg, extrudes):
+ def makeCrossSection(extrude, name):
+ wires = list()
+ shape = extrude.Shape
+
+ for i in shape.slice(Base.Vector(0, 0, 1), cfg.thickness / 2):
+ wires.append(i)
+
+ comp = Part.Compound(wires)
+ cs = doc.addObject("Part::Feature", name + "_Cross_Section")
+ cs.Shape = comp
+ cs.ViewObject.Visibility = False
+ cs.purgeTouched()
+ return cs
+
+ objects = {}
+ for key, extrude in extrudes.items():
+ objects[key] = makeCrossSection(extrude, key.title())
+ return objects
+
+def make(doc, cfg):
+ # Cretate the underlying parts
+ parts = makeBox(doc, cfg)
+
+ # Extrude each part
+ extrudes = makeExtrudes(doc, cfg)
+
+ # Put all extrudes in a group
+ box = doc.addObject("App::DocumentObjectGroup", "Box")
+ for e in extrudes.values():
+ box.addObject(e)
+
+ doc.recompute()
+
+ # Create cross sections for export
+ crossSections = makeCrossSections(doc, cfg, extrudes)
+ crossSectionsGroup = doc.addObject("App::DocumentObjectGroup", "Cross Sections")
+ [crossSectionsGroup.addObject(cs) for cs in crossSections.values()]
+
def removeEverything(doc):
def rm(name):
if hasattr(doc, name):
doc.removeObject(name)
- rm("Top_Extrude")
- rm("Back_Extrude")
- rm("Left_Extrude")
- rm("Front_Extrude")
- rm("Right_Extrude")
- rm("Bottom_Extrude")
-
- rm("Top")
- rm("Back")
- rm("Left")
- rm("Front")
- rm("Right")
- rm("Bottom")
-
+ rm("Box")
+ rm("Cross Sections")
+
+ for key in ['Front', 'Back', 'Left', 'Right', 'Top', 'Bottom']:
+ rm(key + '_Cross_Section')
+ rm(key + '_Extrude')
+ rm(key)