Arch: misc bugfixes in IFC export
This commit is contained in:
parent
007f939731
commit
627e32aa2c
|
@ -483,7 +483,7 @@ def meshToShape(obj,mark=True,fast=True,tol=0.001,flat=False,cut=True):
|
||||||
FreeCAD.ActiveDocument.removeObject(name)
|
FreeCAD.ActiveDocument.removeObject(name)
|
||||||
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature",name)
|
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature",name)
|
||||||
newobj.Shape = solid
|
newobj.Shape = solid
|
||||||
newobj.Placement = plac
|
#newobj.Placement = plac #the placement is already computed in the mesh
|
||||||
if (not solid.isClosed()) or (not solid.isValid()):
|
if (not solid.isClosed()) or (not solid.isValid()):
|
||||||
if mark:
|
if mark:
|
||||||
newobj.ViewObject.ShapeColor = (1.0,0.0,0.0,1.0)
|
newobj.ViewObject.ShapeColor = (1.0,0.0,0.0,1.0)
|
||||||
|
|
|
@ -514,76 +514,82 @@ class _Roof(ArchComponent.Component):
|
||||||
self.baseface = None
|
self.baseface = None
|
||||||
|
|
||||||
base = None
|
base = None
|
||||||
if obj.Base and obj.Angles:
|
if obj.Base:
|
||||||
w = None
|
if not obj.Angles:
|
||||||
if obj.Base.isDerivedFrom("Part::Feature"):
|
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||||
if (obj.Base.Shape.Faces and obj.Face):
|
if obj.Base.Shape.Solids:
|
||||||
w = obj.Base.Shape.Faces[obj.Face-1].Wires[0]
|
base = obj.Base.Shape.copy()
|
||||||
elif obj.Base.Shape.Wires:
|
print "base", base
|
||||||
w = obj.Base.Shape.Wires[0]
|
else:
|
||||||
if w:
|
w = None
|
||||||
if w.isClosed():
|
if obj.Base.isDerivedFrom("Part::Feature"):
|
||||||
self.profilsDico = []
|
if (obj.Base.Shape.Faces and obj.Face):
|
||||||
self.shps = []
|
w = obj.Base.Shape.Faces[obj.Face-1].Wires[0]
|
||||||
self.subVolshps = []
|
elif obj.Base.Shape.Wires:
|
||||||
heights = []
|
w = obj.Base.Shape.Wires[0]
|
||||||
edges = DraftGeomUtils.sortEdges(w.Edges)
|
if w:
|
||||||
l = len(edges)
|
if w.isClosed():
|
||||||
print("le contour contient "+str(l)+" aretes")
|
self.profilsDico = []
|
||||||
for i in range(l):
|
self.shps = []
|
||||||
self.makeRoofProfilsDic(i, obj.Angles[i], obj.Runs[i], obj.IdRel[i], obj.Overhang[i], obj.Thickness[i])
|
self.subVolshps = []
|
||||||
for i in range(l):
|
heights = []
|
||||||
self.calcMissingData(i)
|
edges = DraftGeomUtils.sortEdges(w.Edges)
|
||||||
for i in range(l):
|
l = len(edges)
|
||||||
self.calcEdgeGeometry(edges, i)
|
print("le contour contient "+str(l)+" aretes")
|
||||||
for i in range(l):
|
for i in range(l):
|
||||||
self.calcDraftEdges(i)
|
self.makeRoofProfilsDic(i, obj.Angles[i], obj.Runs[i], obj.IdRel[i], obj.Overhang[i], obj.Thickness[i])
|
||||||
for i in range(l):
|
for i in range(l):
|
||||||
self.calcEave(i)
|
self.calcMissingData(i)
|
||||||
for p in self.profilsDico:
|
for i in range(l):
|
||||||
heights.append(p["height"])
|
self.calcEdgeGeometry(edges, i)
|
||||||
obj.Heights = heights
|
for i in range(l):
|
||||||
for i in range(l):
|
self.calcDraftEdges(i)
|
||||||
self.getRoofPaneProject(i)
|
for i in range(l):
|
||||||
profilCurrent = self.findProfil(i)
|
self.calcEave(i)
|
||||||
midpoint = DraftGeomUtils.findMidpoint(profilCurrent["edge"])
|
for p in self.profilsDico:
|
||||||
ptsPaneProject = profilCurrent["points"]
|
heights.append(p["height"])
|
||||||
lp = len(ptsPaneProject)
|
obj.Heights = heights
|
||||||
if lp != 0:
|
for i in range(l):
|
||||||
#print FreeCAD.Vector(ptsPaneProject[0])
|
self.getRoofPaneProject(i)
|
||||||
ptsPaneProject.append(ptsPaneProject[0])
|
profilCurrent = self.findProfil(i)
|
||||||
edgesWire = []
|
midpoint = DraftGeomUtils.findMidpoint(profilCurrent["edge"])
|
||||||
for p in range(lp):
|
ptsPaneProject = profilCurrent["points"]
|
||||||
edge = Part.makeLine(ptsPaneProject[p],ptsPaneProject[p+1])
|
lp = len(ptsPaneProject)
|
||||||
edgesWire.append(edge)
|
if lp != 0:
|
||||||
wire = Part.Wire(edgesWire)
|
#print FreeCAD.Vector(ptsPaneProject[0])
|
||||||
d = wire.BoundBox.DiagonalLength
|
ptsPaneProject.append(ptsPaneProject[0])
|
||||||
thicknessV = profilCurrent["thickness"]/(math.cos(math.radians(profilCurrent["angle"])))
|
edgesWire = []
|
||||||
overhangV = profilCurrent["overhang"]*math.tan(math.radians(profilCurrent["angle"]))
|
for p in range(lp):
|
||||||
if wire.isClosed():
|
edge = Part.makeLine(ptsPaneProject[p],ptsPaneProject[p+1])
|
||||||
f = Part.Face(wire)
|
edgesWire.append(edge)
|
||||||
#Part.show(f)
|
wire = Part.Wire(edgesWire)
|
||||||
f = f.extrude(FreeCAD.Vector(0,0,profilCurrent["height"]+2*thicknessV+2*overhangV))
|
d = wire.BoundBox.DiagonalLength
|
||||||
f.translate(FreeCAD.Vector(0.0,0.0,-2*overhangV))
|
thicknessV = profilCurrent["thickness"]/(math.cos(math.radians(profilCurrent["angle"])))
|
||||||
ptsPaneProfil=[FreeCAD.Vector(-profilCurrent["overhang"],-overhangV,0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"],0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"]+thicknessV,0.0),FreeCAD.Vector(-profilCurrent["overhang"],-overhangV+thicknessV,0.0)]
|
overhangV = profilCurrent["overhang"]*math.tan(math.radians(profilCurrent["angle"]))
|
||||||
self.createProfilShape (ptsPaneProfil, midpoint, profilCurrent["rot"], profilCurrent["vec"], profilCurrent["run"], d, self.shps, f)
|
if wire.isClosed():
|
||||||
## subVolume shape
|
f = Part.Face(wire)
|
||||||
ptsSubVolumeProfil=[FreeCAD.Vector(-profilCurrent["overhang"],-overhangV,0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"],0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"]+10000,0.0),FreeCAD.Vector(0.0,profilCurrent["height"]+10000,0.0)]
|
#Part.show(f)
|
||||||
self.createProfilShape (ptsSubVolumeProfil, midpoint, profilCurrent["rot"], profilCurrent["vec"], profilCurrent["run"], d, self.subVolshps, f)
|
f = f.extrude(FreeCAD.Vector(0,0,profilCurrent["height"]+2*thicknessV+2*overhangV))
|
||||||
|
f.translate(FreeCAD.Vector(0.0,0.0,-2*overhangV))
|
||||||
|
ptsPaneProfil=[FreeCAD.Vector(-profilCurrent["overhang"],-overhangV,0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"],0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"]+thicknessV,0.0),FreeCAD.Vector(-profilCurrent["overhang"],-overhangV+thicknessV,0.0)]
|
||||||
|
self.createProfilShape (ptsPaneProfil, midpoint, profilCurrent["rot"], profilCurrent["vec"], profilCurrent["run"], d, self.shps, f)
|
||||||
|
## subVolume shape
|
||||||
|
ptsSubVolumeProfil=[FreeCAD.Vector(-profilCurrent["overhang"],-overhangV,0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"],0.0),FreeCAD.Vector(profilCurrent["run"],profilCurrent["height"]+10000,0.0),FreeCAD.Vector(0.0,profilCurrent["height"]+10000,0.0)]
|
||||||
|
self.createProfilShape (ptsSubVolumeProfil, midpoint, profilCurrent["rot"], profilCurrent["vec"], profilCurrent["run"], d, self.subVolshps, f)
|
||||||
|
|
||||||
## SubVolume
|
## SubVolume
|
||||||
self.sub = self.subVolshps.pop()
|
self.sub = self.subVolshps.pop()
|
||||||
for s in self.subVolshps:
|
for s in self.subVolshps:
|
||||||
self.sub = self.sub.fuse(s)
|
self.sub = self.sub.fuse(s)
|
||||||
self.sub = self.sub.removeSplitter()
|
self.sub = self.sub.removeSplitter()
|
||||||
if not self.sub.isNull():
|
if not self.sub.isNull():
|
||||||
if not DraftGeomUtils.isNull(pl):
|
if not DraftGeomUtils.isNull(pl):
|
||||||
self.sub.Placement = pl
|
self.sub.Placement = pl
|
||||||
## BaseVolume
|
## BaseVolume
|
||||||
base = Part.makeCompound(self.shps)
|
base = Part.makeCompound(self.shps)
|
||||||
if not base.isNull():
|
if not base.isNull():
|
||||||
if not DraftGeomUtils.isNull(pl):
|
if not DraftGeomUtils.isNull(pl):
|
||||||
base.Placement = pl
|
base.Placement = pl
|
||||||
base = self.processSubShapes(obj,base)
|
base = self.processSubShapes(obj,base)
|
||||||
if base:
|
if base:
|
||||||
if not base.isNull():
|
if not base.isNull():
|
||||||
|
|
|
@ -543,19 +543,23 @@ def export(exportList,filename):
|
||||||
props = []
|
props = []
|
||||||
for key in obj.IfcAttributes:
|
for key in obj.IfcAttributes:
|
||||||
if not (key in ["IfcUID","FlagForceBrep"]):
|
if not (key in ["IfcUID","FlagForceBrep"]):
|
||||||
tp,val = obj.IfcAttributes[key].strip(")").split("(")
|
r = obj.IfcAttributes[key].strip(")").split("(")
|
||||||
|
tp = r[0]
|
||||||
|
val = "(".join(r[1:])
|
||||||
val = val.strip("'")
|
val = val.strip("'")
|
||||||
val = val.strip('"')
|
val = val.strip('"')
|
||||||
if tp == "IfcLabel":
|
if DEBUG: print " property ",key," : ",str(val), " (", str(tp), ")"
|
||||||
|
if tp in ["IfcLabel","IfcText","IfcIdentifier"]:
|
||||||
val = str(val)
|
val = str(val)
|
||||||
elif tp == "IfcBoolean":
|
elif tp == "IfcBoolean":
|
||||||
if val == ".T.":
|
if val == ".T.":
|
||||||
val = True
|
val = True
|
||||||
else:
|
else:
|
||||||
val = False
|
val = False
|
||||||
|
elif tp == "IfcInteger":
|
||||||
|
val = int(val)
|
||||||
else:
|
else:
|
||||||
val = float(val)
|
val = float(val)
|
||||||
if DEBUG: print " property ",key," : ",str(val), " (", str(tp), ")"
|
|
||||||
props.append(ifcfile.createIfcPropertySingleValue(str(key),None,ifcfile.create_entity(str(tp),val),None))
|
props.append(ifcfile.createIfcPropertySingleValue(str(key),None,ifcfile.create_entity(str(tp),val),None))
|
||||||
if props:
|
if props:
|
||||||
pset = ifcfile.createIfcPropertySet(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'PropertySet',None,props)
|
pset = ifcfile.createIfcPropertySet(ifcopenshell.guid.compress(uuid.uuid1().hex),history,'PropertySet',None,props)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user