Arch: Added alternative to export multi-solids objects to IFC

This commit is contained in:
Yorik van Havre 2014-04-23 17:20:57 -03:00
parent dcc81c513d
commit 3387992358
4 changed files with 49 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -279,6 +279,26 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="Gui::PrefCheckBox" name="checkBox_3">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Objects containing multiple solids are normally exported as multiple representations. Some applications don't like that,though. You can use this option to unite these solids into one.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Join multi-solid objects</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ifcJoinSolids</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View File

@ -385,6 +385,18 @@ class IfcDocument(object):
f.write(l)
f.close()
def union(self,solids):
"""union(solids): creates a boolean union between all the solids of the list"""
if len(solids) == 1:
return solids[0]
else:
s1 = solids.pop(0)
s2 = solids.pop(0)
base = create(self._fileobject,"IfcBooleanResult",["UNION",s1,s2])
for s in solids:
base = create(self._fileobject,"IfcBooleanResult",["UNION",base,s])
return base
def addPlacement(self,reference=None,origin=(0,0,0),xaxis=(1,0,0),zaxis=(0,0,1),local=True):
"""addPlacement([reference,origin,xaxis,zaxis,local]): adds a placement. origin,
xaxis and zaxis can be either tuples or 3d vectors. If local is False, a global

View File

@ -63,7 +63,7 @@ def insert(filename,docname,skip=None):
def getConfig():
"Gets Arch IFC import preferences"
global CREATE_IFC_GROUPS, ASMESH, PREFIX_NUMBERS, FORCE_PYTHON_PARSER, SEPARATE_OPENINGS, SEPARATE_PLACEMENTS
global CREATE_IFC_GROUPS, ASMESH, PREFIX_NUMBERS, FORCE_PYTHON_PARSER, SEPARATE_OPENINGS, SEPARATE_PLACEMENTS, JOINSOLIDS
CREATE_IFC_GROUPS = False
IMPORT_IFC_FURNITURE = False
ASMESH = ["IfcFurnishingElement"]
@ -77,6 +77,7 @@ def getConfig():
SEPARATE_OPENINGS = p.GetBool("ifcSeparateOpenings",False)
SEPARATE_PLACEMENTS = p.GetBool("ifcSeparatePlacements",False)
PREFIX_NUMBERS = p.GetBool("ifcPrefixNumbers",False)
JOINSOLIDS = p.GetBool("ifcJoinSolids",False)
skiplist = p.GetString("ifcSkip","")
if skiplist:
SKIP = skiplist.split(",")
@ -1048,7 +1049,10 @@ def export(exportList,filename):
elif gdata[0] == "circle":
ifc.addWall( ifc.addExtrudedCircle(gdata[1], gdata[2], gdata[3]), storey=parent, name=name )
elif fdata:
ifc.addWall( [ifc.addFacetedBrep(f) for f in fdata], storey=parent, name=name )
if JOINSOLIDS:
ifc.addWall( ifc.join([ifc.addFacetedBrep(f) for f in fdata]), storey=parent, name=name )
else:
ifc.addWall( [ifc.addFacetedBrep(f) for f in fdata], storey=parent, name=name )
elif otype == "Structure":
placement = None
@ -1082,7 +1086,10 @@ def export(exportList,filename):
placement = ifc.addPlacement(origin=basepoint)
ifc.addStructure( role, ifc.addExtrudedCircle(gdata[1], gdata[2], gdata[3]), storey=parent, placement=placement, name=name, extrusion=True )
elif fdata:
ifc.addStructure( role, [ifc.addFacetedBrep(f) for f in fdata], storey=parent, name=name )
if JOINSOLIDS:
ifc.addStructure( role, ifc.join([ifc.addFacetedBrep(f) for f in fdata]), storey=parent, name=name )
else:
ifc.addStructure( role, [ifc.addFacetedBrep(f) for f in fdata], storey=parent, name=name )
elif otype == "Window":
if parent:
@ -1104,7 +1111,10 @@ def export(exportList,filename):
if gdata[0] == "polyline":
ifc.addWindow( role, obj.Width*scaling, obj.Height*scaling, ifc.addExtrudedPolyline(gdata[1], gdata[2]), host=parent, name=name )
elif fdata:
ifc.addWindow( role, obj.Width*scaling, obj.Height*scaling, [ifc.addFacetedBrep(f) for f in fdata], host=parent, name=name )
if JOINSOLIDS:
ifc.addWindow( role, obj.Width*scaling, obj.Height*scaling, ifc.union([ifc.addFacetedBrep(f) for f in fdata]), host=parent, name=name )
else:
ifc.addWindow( role, obj.Width*scaling, obj.Height*scaling, [ifc.addFacetedBrep(f) for f in fdata], host=parent, name=name )
else:
print "IFC export: object type ", otype, " is not supported yet."