Arch: Small fixes around Arch and Draft

This commit is contained in:
Yorik van Havre
2014-02-26 18:01:24 -03:00
parent 0b0a57a4eb
commit 48d63f8020
6 changed files with 60 additions and 41 deletions

View File

@@ -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"):
@@ -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
@@ -873,7 +873,7 @@ class _CommandRemove:
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:
@@ -885,7 +885,7 @@ class _CommandRemove:
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()

View File

@@ -330,7 +330,7 @@ class Component:
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():
@@ -345,36 +345,40 @@ class Component:
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:
@@ -407,7 +411,10 @@ class Component:
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:

View File

@@ -90,7 +90,7 @@ class _Stairs(ArchComponent.Component):
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"))
@@ -116,6 +116,7 @@ class _Stairs(ArchComponent.Component):
import Part
self.steps = []
self.pseudosteps = []
self.structures = []
pl = obj.Placement
landings = 0
@@ -170,6 +171,12 @@ class _Stairs(ArchComponent.Component):
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:
@@ -227,7 +234,9 @@ class _Stairs(ArchComponent.Component):
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 = []
@@ -321,7 +330,7 @@ class _Stairs(ArchComponent.Component):
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):
@@ -334,7 +343,9 @@ class _Stairs(ArchComponent.Component):
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 = []

View File

@@ -136,7 +136,7 @@ class ArchWorkbench(Workbench):
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"

View File

@@ -2901,6 +2901,7 @@ class Trimex(Modifier):
else:
self.obj.Shape = newshape
self.doc.commitTransaction()
self.doc.recompute()
for g in self.ghost: g.off()
def finish(self,closed=False):

View File

@@ -158,7 +158,7 @@ class DraftWorkbench (Workbench):
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:
@@ -166,7 +166,7 @@ class DraftWorkbench (Workbench):
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"