Arch: Added IFC import option to replace project,site and building with a group
This commit is contained in:
@@ -7,26 +7,17 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>463</width>
|
||||
<height>421</height>
|
||||
<height>466</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>IFC-Export</string>
|
||||
<string>IFC export</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
|
||||
@@ -7,26 +7,17 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>463</width>
|
||||
<height>495</height>
|
||||
<height>577</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>IFC</string>
|
||||
<string>IFC import</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
@@ -394,6 +385,22 @@ FreeCAD object properties</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="checkBox">
|
||||
<property name="toolTip">
|
||||
<string>If this option is checked, the default Project, Site and Building objects that are usually found in an IFC file are not imported, and all objects are placed in a Group</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Replace Project, Site and Buiding by Group</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>ifcReplaceProject</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Arch</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -161,7 +161,8 @@ def getPreferences():
|
||||
'IMPORT_PROPERTIES': p.GetBool("ifcImportProperties",False),
|
||||
'SPLIT_LAYERS': p.GetBool("ifcSplitLayers",False),
|
||||
'FITVIEW_ONIMPORT': p.GetBool("ifcFitViewOnImport",False),
|
||||
'ALLOW_INVALID': p.GetBool("ifcAllowInvalid",False)
|
||||
'ALLOW_INVALID': p.GetBool("ifcAllowInvalid",False),
|
||||
'REPLACE_PROJECT': p.GetBool("ifcReplaceProject",False)
|
||||
}
|
||||
|
||||
if preferences['MERGE_MODE_ARCH'] > 0:
|
||||
@@ -299,23 +300,24 @@ def insert(filename,docname,skip=[],only=[],root=None,preferences=None):
|
||||
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
|
||||
|
||||
# Create the base project object
|
||||
if len(ifcfile.by_type("IfcProject")) > 0:
|
||||
projectImporter = importIFCHelper.ProjectImporter(ifcfile, objects)
|
||||
projectImporter.execute()
|
||||
else:
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=39&t=40624
|
||||
print("No IfcProject found in the ifc file. Nothing imported")
|
||||
return doc
|
||||
if not preferences['REPLACE_PROJECT']:
|
||||
if len(ifcfile.by_type("IfcProject")) > 0:
|
||||
projectImporter = importIFCHelper.ProjectImporter(ifcfile, objects)
|
||||
projectImporter.execute()
|
||||
else:
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=39&t=40624
|
||||
print("No IfcProject found in the ifc file. Nothing imported")
|
||||
return doc
|
||||
|
||||
# handle IFC products
|
||||
|
||||
for product in products:
|
||||
|
||||
count += 1
|
||||
|
||||
pid = product.id()
|
||||
guid = product.GlobalId
|
||||
ptype = product.is_a()
|
||||
|
||||
if preferences['DEBUG']: print(count,"/",len(products),"object #"+str(pid),":",ptype,end="")
|
||||
|
||||
# build list of related property sets
|
||||
@@ -382,6 +384,15 @@ def insert(filename,docname,skip=[],only=[],root=None,preferences=None):
|
||||
if ptype in preferences['SKIP']: # preferences-set type skip list
|
||||
if preferences['DEBUG']: print(" skipped.")
|
||||
continue
|
||||
if preferences['REPLACE_PROJECT']: # options-enabled project/site/building skip
|
||||
if ptype in ['IfcProject','IfcSite']:
|
||||
if preferences['DEBUG']: print(" skipped.")
|
||||
continue
|
||||
elif ptype in ['IfcBuilding']:
|
||||
if len(ifcfile.by_type("IfcBuilding")) == 1:
|
||||
# let multiple buildings through...
|
||||
if preferences['DEBUG']: print(" skipped.")
|
||||
continue
|
||||
|
||||
# check if this object is sharing its shape (mapped representation)
|
||||
clone = None
|
||||
@@ -1220,6 +1231,15 @@ def insert(filename,docname,skip=[],only=[],root=None,preferences=None):
|
||||
if l:
|
||||
setattr(p[0],p[1],l)
|
||||
|
||||
# Grouping everything if required
|
||||
if preferences['REPLACE_PROJECT']:
|
||||
rootgroup = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroup","Group")
|
||||
rootgroup.Label = os.path.basename(filename)
|
||||
for key,obj in objects.items():
|
||||
# only add top-level objects
|
||||
if not obj.InList:
|
||||
rootgroup.addObject(obj)
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
if ZOOMOUT and FreeCAD.GuiUp:
|
||||
|
||||
Reference in New Issue
Block a user