Skip to content

Commit

Permalink
Arch: Fixed export to IFC of standalone axes
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jul 31, 2018
1 parent 0865c8a commit 269a4a5
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -1430,7 +1430,7 @@ def export(exportList,filename):
for obj in objectslist:
if obj.isDerivedFrom("Part::Part2DObject"):
annotations.append(obj)
elif obj.isDerivedFrom("App::Annotation"):
elif obj.isDerivedFrom("App::Annotation") or (Draft.getType(obj) == "DraftText"):
annotations.append(obj)
elif obj.isDerivedFrom("Part::Feature"):
if obj.Shape:
Expand Down Expand Up @@ -1519,10 +1519,25 @@ def export(exportList,filename):
# export grids

if ifctype in ["IfcAxis","IfcAxisSystem","IfcGrid"]:
ifctype = "IfcGrid"
ifcaxes = []
ifcpols = []
for axg in obj.Proxy.getAxisData(obj):
if ifctype == "IfcAxis":
# make sure this axis is not included in something else already
standalone = True
for p in obj.InList:
if hasattr(p,"Axes") and (obj in p.Axes):
if p in objectslist:
axgroups = []
standalone = False
break
if standalone:
axgroups = [obj.Proxy.getAxisData(obj)]
else:
axgroups = obj.Proxy.getAxisData(obj)
if not axgroups:
continue
ifctype = "IfcGrid"
for axg in axgroups:
ifcaxg = []
for ax in axg:
p1 = ifcbin.createIfcCartesianPoint(tuple(FreeCAD.Vector(ax[0]).multiply(0.001)))
Expand All @@ -1543,20 +1558,21 @@ def export(exportList,filename):
if len(ifcaxes) > 1:
v = ifcaxes[1]
if len(ifcaxes) > 2:
v = ifcaxes[2]
if DEBUG: print(str(count).ljust(3)," : ", ifctype, " (",str(len(ifcpols)),"axes ) : ",name)
xvc = ifcbin.createIfcDirection((1.0,0.0,0.0))
zvc = ifcbin.createIfcDirection((0.0,0.0,1.0))
ovc = ifcbin.createIfcCartesianPoint((0.0,0.0,0.0))
gpl = ifcbin.createIfcAxis2Placement3D(ovc,zvc,xvc)
plac = ifcbin.createIfcLocalPlacement(gpl)
cset = ifcfile.createIfcGeometricCurveSet(ifcpols)
#subc = ifcfile.createIfcGeometricRepresentationSubContext('FootPrint','Model',context,None,"MODEL_VIEW",None,None,None,None,None)
srep = ifcfile.createIfcShapeRepresentation(context,'FootPrint',"GeometricCurveSet",ifcpols)
pdef = ifcfile.createIfcProductDefinitionShape(None,None,[srep])
grid = ifcfile.createIfcGrid(uid,history,name,description,None,plac,pdef,u,v,w)
products[obj.Name] = grid
count += 1
w = ifcaxes[2]
if u and v:
if DEBUG: print(str(count).ljust(3)," : ", ifctype, " (",str(len(ifcpols)),"axes ) : ",name)
xvc = ifcbin.createIfcDirection((1.0,0.0,0.0))
zvc = ifcbin.createIfcDirection((0.0,0.0,1.0))
ovc = ifcbin.createIfcCartesianPoint((0.0,0.0,0.0))
gpl = ifcbin.createIfcAxis2Placement3D(ovc,zvc,xvc)
plac = ifcbin.createIfcLocalPlacement(gpl)
cset = ifcfile.createIfcGeometricCurveSet(ifcpols)
#subc = ifcfile.createIfcGeometricRepresentationSubContext('FootPrint','Model',context,None,"MODEL_VIEW",None,None,None,None,None)
srep = ifcfile.createIfcShapeRepresentation(context,'FootPrint',"GeometricCurveSet",ifcpols)
pdef = ifcfile.createIfcProductDefinitionShape(None,None,[srep])
grid = ifcfile.createIfcGrid(uid,history,name,description,None,plac,pdef,u,v,w)
products[obj.Name] = grid
count += 1
continue

from ArchComponent import IFCTYPES
Expand Down

0 comments on commit 269a4a5

Please sign in to comment.