Skip to content

Commit

Permalink
Arch: Fixed IFC export of arrays - issue FreeCAD#12802
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Mar 12, 2024
1 parent 9140327 commit 4133053
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/Mod/Arch/exportIFC.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,7 @@ def export(exportList, filename, colors=None, preferences=None):

assemblyElements = []

# if ifctype == "IfcArray":
# FIXME: the first array element is not placed correct if the array is not on coordinate origin
# https://forum.freecad.org/viewtopic.php?f=39&t=50085&p=431476#p431476
# workaround: do not use the assembly in ifc but a normal compound instead
if False:
if ifctype == "IfcArray":
clonedeltas = []
if obj.ArrayType == "ortho":
for i in range(obj.NumberX):
Expand All @@ -384,8 +380,6 @@ def export(exportList, filename, colors=None, preferences=None):
for k in range(obj.NumberZ):
if k > 0:
clonedeltas.append(obj.Placement.Base+(i*obj.IntervalX)+(j*obj.IntervalY)+(k*obj.IntervalZ))

#print("clonedeltas:",clonedeltas)
if clonedeltas:
ifctype = "IfcElementAssembly"
for delta in clonedeltas:
Expand All @@ -412,12 +406,7 @@ def export(exportList, filename, colors=None, preferences=None):
preferences
)
assemblyElements.append(subproduct)
# if an array was handled assemblyElements is not empty
# if assemblyElements is not empty later on
# the own Shape is ignored if representation is retrieved
# this because we will build an assembly for the assemblyElements
# from here and the assembly itself should not have a representation
if ifctype in ["IfcApp::Part","IfcPart::Compound","IfcElementAssembly"]:
elif ifctype in ["IfcApp::Part","IfcPart::Compound","IfcElementAssembly"]:
if hasattr(obj,"Group"):
group = obj.Group
elif hasattr(obj,"Links"):
Expand Down Expand Up @@ -2302,6 +2291,8 @@ def getRepresentation(
gpl = ifcbin.createIfcAxis2Placement3D()
repmap = ifcfile.createIfcRepresentationMap(gpl,subrep)
pla = obj.getGlobalPlacement()
if isinstance(forceclone,FreeCAD.Vector):
pla.Base += forceclone
axis1 = ifcbin.createIfcDirection(tuple(pla.Rotation.multVec(FreeCAD.Vector(1,0,0))))
axis2 = ifcbin.createIfcDirection(tuple(pla.Rotation.multVec(FreeCAD.Vector(0,1,0))))
origin = ifcbin.createIfcCartesianPoint(tuple(FreeCAD.Vector(pla.Base).multiply(preferences['SCALE_FACTOR'])))
Expand Down

0 comments on commit 4133053

Please sign in to comment.