Skip to content

Commit

Permalink
Arch: Small fixes around Arch and Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Feb 26, 2014
1 parent eed06cc commit 995b146
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -81,7 +81,7 @@ def addComponents(objectsList,host):
if not o in c:
c.append(o)
host.Group = c
elif hostType in ["Wall","Structure","Window","Roof"]:
elif hostType in ["Wall","Structure","Window","Roof","Stairs"]:
import DraftGeomUtils
a = host.Additions
if hasattr(host,"Axes"):
Expand Down Expand Up @@ -122,7 +122,7 @@ def removeComponents(objectsList,host=None):
if not isinstance(objectsList,list):
objectsList = [objectsList]
if host:
if Draft.getType(host) in ["Wall","Structure"]:
if Draft.getType(host) in ["Wall","Structure","Window","Roof","Stairs"]:
if hasattr(host,"Tool"):
if objectsList[0] == host.Tool:
host.Tool = None
Expand Down Expand Up @@ -873,7 +873,7 @@ def Activated(self):
FreeCADGui.doCommand("Arch.removeSpaceBoundaries( FreeCAD.ActiveDocument."+sel[-1].Name+", FreeCADGui.Selection.getSelection() )")
else:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Ungrouping")))
if (Draft.getType(sel[-1]) in ["Wall","Structure"]) and (len(sel) > 1):
if (Draft.getType(sel[-1]) in ["Wall","Structure","Stairs","Roof","Window"]) and (len(sel) > 1):
host = sel.pop()
ss = "["
for o in sel:
Expand All @@ -885,7 +885,7 @@ def Activated(self):
FreeCADGui.doCommand("Arch.removeComponents("+ss+",FreeCAD.ActiveDocument."+host.Name+")")
else:
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.removeComponents(Arch.ActiveDocument."+sel[-1].Name+")")
FreeCADGui.doCommand("Arch.removeComponents(FreeCAD.ActiveDocument."+sel[-1].Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()

Expand Down
69 changes: 38 additions & 31 deletions src/Mod/Arch/ArchComponent.py
Expand Up @@ -330,7 +330,7 @@ def hideSubobjects(self,obj,prop):

def processSubShapes(self,obj,base,pl=None):
"Adds additions and subtractions to a base shape"
import Draft
import Draft,Part

if pl:
if pl.isNull():
Expand All @@ -345,36 +345,40 @@ def processSubShapes(self,obj,base,pl=None):
if base:
if base.isNull():
base = None

# special case, both walls with coinciding endpoints
import ArchWall
js = ArchWall.mergeShapes(o,obj)
if js:
add = js.cut(base)
if pl:
add.Placement = add.Placement.multiply(pl)
base = base.fuse(add)

elif (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window")):
f = o.Proxy.getSubVolume(o)
if f:
if base.Solids and f.Solids:
if pl:
f.Placement = f.Placement.multiply(pl)
base = base.cut(f)

elif o.isDerivedFrom("Part::Feature"):
if o.Shape:
if not o.Shape.isNull():
if o.Shape.Solids:
s = o.Shape.copy()

if base:
# special case, both walls with coinciding endpoints
import ArchWall
js = ArchWall.mergeShapes(o,obj)
if js:
add = js.cut(base)
if pl:
add.Placement = add.Placement.multiply(pl)
base = base.fuse(add)

elif (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window")):
f = o.Proxy.getSubVolume(o)
if f:
if base.Solids and f.Solids:
if pl:
s.Placement = s.Placement.multiply(pl)
if base:
if base.Solids:
base = base.fuse(s)
else:
base = s
f.Placement = f.Placement.multiply(pl)
base = base.cut(f)

elif o.isDerivedFrom("Part::Feature"):
if o.Shape:
if not o.Shape.isNull():
if o.Shape.Solids:
s = o.Shape.copy()
if pl:
s.Placement = s.Placement.multiply(pl)
if base:
if base.Solids:
try:
base = base.fuse(s)
except:
print "Arch: unable to fuse object ",obj.Name, " with ", o.Name
else:
base = s

# treat subtractions
for o in obj.Subtractions:
Expand Down Expand Up @@ -407,7 +411,10 @@ def processSubShapes(self,obj,base,pl=None):
s = o.Shape.copy()
if pl:
s.Placement = s.Placement.multiply(pl)
base = base.cut(s)
try:
base = base.cut(s)
except:
print "Arch: unable to cut object ",o.Name, " from ", obj.Name
return base

class ViewProviderComponent:
Expand Down
19 changes: 15 additions & 4 deletions src/Mod/Arch/ArchStairs.py
Expand Up @@ -90,7 +90,7 @@ def __init__(self,obj):
obj.addProperty("App::PropertyLength","RiserHeight","Steps",translate("Arch","The height of the risers of these stairs"))
obj.addProperty("App::PropertyLength","Nosing","Steps",translate("Arch","The size of the nosing"))
obj.addProperty("App::PropertyLength","TreadThickness","Steps",translate("Arch","The thickness of the treads"))
obj.addProperty("App::PropertyLength","BlondelRatio","Steps",translate("Arch","The Blondel ratio, must be between 62 and 64cm or 24.5 and 25.5in"))
obj.addProperty("App::PropertyFloat","BlondelRatio","Steps",translate("Arch","The Blondel ratio, must be between 62 and 64cm or 24.5 and 25.5in"))

# structural properties
obj.addProperty("App::PropertyEnumeration","Landings","Structure",translate("Arch","The type of landings of these stairs"))
Expand All @@ -116,6 +116,7 @@ def execute(self,obj):

import Part
self.steps = []
self.pseudosteps = []
self.structures = []
pl = obj.Placement
landings = 0
Expand Down Expand Up @@ -170,6 +171,12 @@ def execute(self,obj):
shape = self.processSubShapes(obj,shape,pl)
obj.Shape = shape
obj.Placement = pl
elif self.pseudosteps:
shape = Part.makeCompound(self.pseudosteps)
obj.Shape = shape
obj.Placement = pl
else:
print "unable to calculate a stairs shape"

# compute step data
if obj.NumberOfSteps > 1:
Expand Down Expand Up @@ -227,7 +234,9 @@ def makeStraightLanding(self,obj,edge,numberofsteps=None):
step = Part.Face(Part.makePolygon([p1,p2,p3,p4,p1]))
if obj.TreadThickness.Value:
step = step.extrude(Vector(0,0,abs(obj.TreadThickness.Value)))
self.steps.append(step)
self.steps.append(step)
else:
self.pseudosteps.append(step)

# structure
lProfile = []
Expand Down Expand Up @@ -321,7 +330,7 @@ def makeStraightStairs(self,obj,edge,numberofsteps=None):
vBase = edge.Vertexes[0].Point
vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value))
a = math.atan(vHeight.Length/vLength.Length)
print "stair data:",vLength.Length,":",vHeight.Length
#print "stair data:",vLength.Length,":",vHeight.Length

# steps
for i in range(numberofsteps-1):
Expand All @@ -334,7 +343,9 @@ def makeStraightStairs(self,obj,edge,numberofsteps=None):
step = Part.Face(Part.makePolygon([p1,p2,p3,p4,p1]))
if obj.TreadThickness.Value:
step = step.extrude(Vector(0,0,abs(obj.TreadThickness.Value)))
self.steps.append(step)
self.steps.append(step)
else:
self.pseudosteps.append(step)

# structure
lProfile = []
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/InitGui.py
Expand Up @@ -136,7 +136,7 @@ def Deactivated(self):
Msg("Arch workbench deactivated\n")

def ContextMenu(self, recipient):
self.appendContextMenu("Draft context tools",self.draftcontexttools)
self.appendContextMenu("Utilities",self.draftcontexttools)

def GetClassName(self):
return "Gui::PythonWorkbench"
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Draft/DraftTools.py
Expand Up @@ -2901,6 +2901,7 @@ def trimObject(self):
else:
self.obj.Shape = newshape
self.doc.commitTransaction()
self.doc.recompute()
for g in self.ghost: g.off()

def finish(self,closed=False):
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Draft/InitGui.py
Expand Up @@ -158,15 +158,15 @@ def ContextMenu(self, recipient):
if (FreeCAD.activeDraftCommand == None):
if (FreeCADGui.Selection.getSelection()):
self.appendContextMenu("Draft",self.cmdList+self.modList)
self.appendContextMenu("Draft context tools",self.treecmdList)
self.appendContextMenu("Utilities",self.treecmdList)
else:
self.appendContextMenu("Draft",self.cmdList)
else:
if (FreeCAD.activeDraftCommand.featureName == "Line"):
self.appendContextMenu("",self.lineList)
else:
if (FreeCADGui.Selection.getSelection()):
self.appendContextMenu("Draft context tools",self.treecmdList)
self.appendContextMenu("Utilities",self.treecmdList)

def GetClassName(self):
return "Gui::PythonWorkbench"
Expand Down

0 comments on commit 995b146

Please sign in to comment.