aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-05-29 10:25:16 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-05-29 10:56:08 +0200
commit250455628d78afc402ba60f3765b3fb44d269be2 (patch)
tree7d70fc55840cb3568653d019f72b5545727faf53
parent909e0f8ab2e581a9f6a88de9ada42b5216c6904d (diff)
downloadfreecad-boxer-250455628d78afc402ba60f3765b3fb44d269be2.tar.gz
freecad-boxer-250455628d78afc402ba60f3765b3fb44d269be2.tar.bz2
freecad-boxer-250455628d78afc402ba60f3765b3fb44d269be2.tar.xz
freecad-boxer-250455628d78afc402ba60f3765b3fb44d269be2.zip
o Show the Boxer module on load.
o Extrude all the parts when generating the model.
-rw-r--r--.gitignore3
-rw-r--r--Boxer.py73
-rw-r--r--BoxerGui.py23
-rw-r--r--InitGui.py6
4 files changed, 83 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index 0d20b64..2e141c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
*.pyc
+*.tmp
+tmp.*
+*.tmp.*
diff --git a/Boxer.py b/Boxer.py
index cfcbbc0..164aaff 100644
--- a/Boxer.py
+++ b/Boxer.py
@@ -214,6 +214,7 @@ def makeBoxSide(cfg, boxSide):
return v
def makeBox(doc, cfg):
+ objects = {}
# front back left
# right top bottom
@@ -223,34 +224,94 @@ def makeBox(doc, cfg):
m.move(cfg.outerWidth * -0.55, 0, 0)
s = Part.makePolygon(makeBoxSide(cfg, BoxSide.front))
s.transformShape(m)
- doc.addObject("Part::Feature", "Front").Shape = s
+ front = doc.addObject("Part::Feature", "Front")
+ front.Shape = s
m = Matrix()
m.move(cfg.outerWidth * 0.55, 0, 0)
s = Part.makePolygon(makeBoxSide(cfg, BoxSide.back))
s.transformShape(m)
- doc.addObject("Part::Feature", "Back").Shape = s
+ back = doc.addObject("Part::Feature", "Back")
+ back.Shape = s
m = Matrix()
m.move(cfg.outerWidth * 1.60, 0, 0)
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.left))
l.transformShape(m)
- doc.addObject("Part::Feature", "Left").Shape = l
+ left = doc.addObject("Part::Feature", "Left")
+ left.Shape = l
m = Matrix()
m.move(cfg.outerWidth * -0.55, cfg.outerWidth * -1.1, 0)
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.right))
l.transformShape(m)
- doc.addObject("Part::Feature", "Right").Shape = l
+ right = doc.addObject("Part::Feature", "Right")
+ right.Shape = l
m = Matrix()
m.move(cfg.outerWidth * 0.55, cfg.outerWidth * -1.1, 0)
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.top))
l.transformShape(m)
- doc.addObject("Part::Feature", "Top").Shape = l
+ top = doc.addObject("Part::Feature", "Top")
+ top.Shape = l
m = Matrix()
m.move(cfg.outerWidth * 1.60, cfg.outerWidth * -1.1, 0)
l = Part.makePolygon(makeBoxSide(cfg, BoxSide.bottom))
l.transformShape(m)
- doc.addObject("Part::Feature", "Bottom").Shape = l
+ bottom = doc.addObject("Part::Feature", "Bottom")
+ bottom.Shape = l
+
+ return {'front': front, 'back': back,
+ 'left': left, 'right': right,
+ 'top': top, 'bottom': bottom}
+
+def makeExtrudes(doc, cfg):
+
+ def makeExtrude(doc, cfg, name, part):
+ extrude = doc.addObject("Part::Extrusion", name + "_Extrude")
+ extrude.Base = part
+ extrude.Dir = (0, 0, cfg.thickness)
+ extrude.Solid = (True)
+ extrude.TaperAngle = (0)
+ extrude.Label = name + ' Extrude'
+
+ partView = part.ViewObject
+ extrudeView = extrude.ViewObject
+
+ if partView is not None and extrudeView is not None:
+ partView.Visibility = False
+ extrudeView.ShapeColor = partView.ShapeColor
+ extrudeView.LineColor = partView.LineColor
+ extrudeView.PointColor = partView.PointColor
+
+ return extrude
+
+ objects = {}
+ objects['front'] = makeExtrude(doc, cfg, "Front", doc.Front)
+ objects['back'] = makeExtrude(doc, cfg, "Back", doc.Back)
+ objects['left'] = makeExtrude(doc, cfg, "Left", doc.Left)
+ objects['right'] = makeExtrude(doc, cfg, "Right", doc.Right)
+ objects['top'] = makeExtrude(doc, cfg, "Top", doc.Top)
+ objects['bottom'] = makeExtrude(doc, cfg, "Bottom", doc.Bottom)
+ return objects
+
+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")
+
diff --git a/BoxerGui.py b/BoxerGui.py
index b4d6258..853c2be 100644
--- a/BoxerGui.py
+++ b/BoxerGui.py
@@ -68,22 +68,19 @@ class BoxerGui(object):
self.cfg.prt()
self.removeBox()
doc = FreeCAD.ActiveDocument
- Boxer.makeBox(doc, self.cfg)
+ parts = Boxer.makeBox(doc, self.cfg)
+ extrudes = Boxer.makeExtrudes(doc, self.cfg)
+ print(extrudes)
+ group = doc.addObject("App::DocumentObjectGroup", "Box")
+# [group.addObject(e) for e in extrudes.values()]
+ for e in extrudes.values():
+ print("e:" + str(e))
+ group.addObject(e)
+ doc.recompute()
def removeBox(self):
doc = FreeCAD.ActiveDocument
-
- def rm(name):
- o = getattr(doc, name, None);
- if hasattr(doc, name):
- doc.removeObject(name)
-
- rm("Top")
- rm("Back")
- rm("Left")
- rm("Front")
- rm("Right")
- rm("Bottom")
+ Boxer.removeEverything(doc)
gui = BoxerGui()
gui.setupGui()
diff --git a/InitGui.py b/InitGui.py
index b200dc8..fe85dd3 100644
--- a/InitGui.py
+++ b/InitGui.py
@@ -85,16 +85,16 @@ class BoxerWorkbench(Workbench):
def Initialize(self):
self.list = ["BoxerMakeBox", "BoxerRemoveBox", "BoxerShowPanel"]
self.appendToolbar("Boxer Commands", self.list)
- import BoxerGui
+ import BoxerGui # Loads the Boxer modules
def Activated(self):
- return
+ Gui.runCommand('BoxerShowPanel')
+ return
def Deactivated(self):
return
def ContextMenu(self, recipient):
- # "recipient" will be either "view" or "tree"
self.appendContextMenu("Boxer", self.list)
def GetClassName(self):