Skip to content

Commit

Permalink
Arch: misc bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jul 26, 2014
1 parent 6b1e6a6 commit d5469ba
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 61 deletions.
10 changes: 5 additions & 5 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -766,15 +766,15 @@ def toggleIfcBrepFlag(obj):
FreeCAD.Console.PrintMessage(translate("Arch","Object doesn't have settable IFC Attributes"))
else:
d = obj.IfcAttributes
if "ForceBrep" in d.keys():
if d["ForceBrep"] == "True":
d["ForceBrep"] = "False"
if "FlagForceBrep" in d.keys():
if d["FlagForceBrep"] == "True":
d["FlagForceBrep"] = "False"
FreeCAD.Console.PrintMessage(translate("Arch","Disabling Brep force flag of object")+" "+obj.Label+"\n")
else:
d["ForceBrep"] = "True"
d["FlagForceBrep"] = "True"
FreeCAD.Console.PrintMessage(translate("Arch","Enabling Brep force flag of object")+" "+obj.Label+"\n")
else:
d["ForceBrep"] = "True"
d["FlagForceBrep"] = "True"
FreeCAD.Console.PrintMessage(translate("Arch","Enabling Brep force flag of object")+" "+obj.Label+"\n")
obj.IfcAttributes = d

Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Arch/ArchComponent.py
Expand Up @@ -69,7 +69,7 @@ def addToComponent(compobject,addobject,mod=None):
if Draft.getType(addobject) == "Axis":
l = getattr(compobject,mod)
l.append(addobject)
setattr(compobject,mod,l)
setattr(compobject,mod,l)
else:
l = getattr(compobject,mod)
l.append(addobject)
Expand Down Expand Up @@ -352,6 +352,8 @@ def getAxis(self,obj):

def getProfiles(self,obj,noplacement=False):
"Returns the base profile(s) of this component, if applicable"
if not obj.Shape: return []
if obj.Shape.isNull(): return []
wires = []
n,l,w,h = self.getDefaultValues(obj)
if obj.Base:
Expand Down Expand Up @@ -411,7 +413,7 @@ def getProfiles(self,obj,noplacement=False):
wires.append(sh)
else:
wires.append(wire)
else:
elif Draft.getType(obj) in ["Wall","Structure"]:
if (Draft.getType(obj) == "Structure") and (l > h):
if noplacement:
h2 = h/2 or 0.5
Expand Down
106 changes: 54 additions & 52 deletions src/Mod/Arch/ArchStairs.py
Expand Up @@ -60,8 +60,6 @@ def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=t
obj.Height = p.GetFloat("StairsHeight",3000.0)
if steps:
obj.NumberOfSteps = steps
else:
obj.NumberOfSteps = p.GetInt("StairsSteps",17)
return obj


Expand All @@ -77,13 +75,14 @@ def IsActive(self):
return not FreeCAD.ActiveDocument is None

def Activated(self):
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Stairs"))
FreeCADGui.doCommand("import Arch")
if len(FreeCADGui.Selection.getSelection()) == 1:
n = FreeCADGui.Selection.getSelection()[0].Name
FreeCADGui.doCommand("Arch.makeStairs(baseobj=FreeCAD.ActiveDocument."+n+")")
else:
FreeCADGui.doCommand("Arch.makeStairs()")
FreeCADGui.doCommand("Arch.makeStairs(steps="+str(p.GetInt("StairsSteps",17))+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()

Expand Down Expand Up @@ -137,64 +136,67 @@ def execute(self,obj):
self.structures = []
pl = obj.Placement
landings = 0

# base tests
if not obj.Width.Value:
return
if not obj.Height.Value:
if not obj.Base:
return
if obj.NumberOfSteps < 2:
return

base = None

if obj.Base:
if not obj.Base.isDerivedFrom("Part::Feature"):
return
if obj.Base.Shape.Solids:
obj.Shape = obj.Base.Shape.copy()
obj.Placement = FreeCAD.Placement(obj.Base.Placement).multiply(pl)
obj.TreadDepth = 0.0
obj.RiserHeight = 0.0
return
if not obj.Base.Shape.Edges:
return
if obj.Base.Shape.Faces:
return
if (len(obj.Base.Shape.Edges) == 1):
edge = obj.Base.Shape.Edges[0]
if isinstance(edge.Curve,Part.Line):
if obj.Landings == "At center":
landings = 1
self.makeStraightStairsWithLanding(obj,edge)
else:
self.makeStraightStairs(obj,edge)
else:
if obj.Landings == "At center":
landings = 1
self.makeCurvedStairsWithLandings(obj,edge)
if hasattr(obj.Base,"Shape"):
if obj.Base.Shape:
if obj.Base.Shape.Solids:
base = obj.Base.Shape.copy()

if (not base) and obj.Width.Value and obj.Height.Value and (obj.NumberOfSteps > 1):
if obj.Base:
if not obj.Base.isDerivedFrom("Part::Feature"):
return
if obj.Base.Shape.Solids:
obj.Shape = obj.Base.Shape.copy()
obj.Placement = FreeCAD.Placement(obj.Base.Placement).multiply(pl)
obj.TreadDepth = 0.0
obj.RiserHeight = 0.0
return
if not obj.Base.Shape.Edges:
return
if obj.Base.Shape.Faces:
return
if (len(obj.Base.Shape.Edges) == 1):
edge = obj.Base.Shape.Edges[0]
if isinstance(edge.Curve,Part.Line):
if obj.Landings == "At center":
landings = 1
self.makeStraightStairsWithLanding(obj,edge)
else:
self.makeStraightStairs(obj,edge)
else:
self.makeCurvedStairs(obj,edge)
else:
if not obj.Length.Value:
return
edge = Part.Line(Vector(0,0,0),Vector(obj.Length.Value,0,0)).toShape()
if obj.Landings == "At center":
landings = 1
self.makeStraightStairsWithLanding(obj,edge)
if obj.Landings == "At center":
landings = 1
self.makeCurvedStairsWithLandings(obj,edge)
else:
self.makeCurvedStairs(obj,edge)
else:
self.makeStraightStairs(obj,edge)
if not obj.Length.Value:
return
edge = Part.Line(Vector(0,0,0),Vector(obj.Length.Value,0,0)).toShape()
if obj.Landings == "At center":
landings = 1
self.makeStraightStairsWithLanding(obj,edge)
else:
self.makeStraightStairs(obj,edge)

if self.structures or self.steps:
shape = Part.makeCompound(self.structures + self.steps)
shape = self.processSubShapes(obj,shape,pl)
obj.Shape = shape
obj.Placement = pl
base = Part.makeCompound(self.structures + self.steps)
elif self.pseudosteps:
shape = Part.makeCompound(self.pseudosteps)
obj.Shape = shape
obj.Placement = pl
else:
print "unable to calculate a stairs shape"

return

base = self.processSubShapes(obj,base,pl)
if base:
if not base.isNull():
obj.Shape = base
obj.Placement = pl

# compute step data
if obj.NumberOfSteps > 1:
l = obj.Length.Value
Expand Down
16 changes: 14 additions & 2 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -1016,8 +1016,8 @@ def export(exportList,filename):
# getting the "Force BREP" flag
brepflag = False
if hasattr(obj,"IfcAttributes"):
if "ForceBrep" in obj.IfcAttributes.keys():
if obj.IfcAttributes["ForceBrep"] == "True":
if "FlagForceBrep" in obj.IfcAttributes.keys():
if obj.IfcAttributes["FlagForceBrep"] == "True":
brepflag = True

if DEBUG: print "Adding " + obj.Label + " as Ifc" + ifctype
Expand Down Expand Up @@ -1324,9 +1324,21 @@ def getIfcBrepFacesData(obj,scale=1,sub=False,tessellation=1):
if not obj.Shape.isNull():
if obj.Shape.isValid():
shape = obj.Shape
elif hasattr(obj,"Terrain"):
if obj.Terrain:
if hasattr(obj.Terrain,"Shape"):
if obj.Terrain.Shape:
if not obj.Terrain.Shape.isNull():
if obj.Terrain.Shape.isValid():
fcshape = obj.Terrain.Shape
if shape:
import Part
sols = []
if fcshape.Solids:
dataset = fcshape.Solids
else:
dataset = fcshape.Shells
print "Warning! object contains no solids"
for sol in shape.Solids:
s = []
curves = False
Expand Down

0 comments on commit d5469ba

Please sign in to comment.