mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
You can now export container data from IFCCSV
This commit is contained in:
@@ -10,7 +10,7 @@ import lark
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
class IfcAttributeExtractor:
|
class IfcAttributeSetter:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_element_key(ifc_file, element, key, value):
|
def set_element_key(ifc_file, element, key, value):
|
||||||
if key == "type" and element.is_a() != value:
|
if key == "type" and element.is_a() != value:
|
||||||
@@ -22,14 +22,14 @@ class IfcAttributeExtractor:
|
|||||||
return element
|
return element
|
||||||
if key[0:3] == "Qto":
|
if key[0:3] == "Qto":
|
||||||
qto, prop = key.split(".", 1)
|
qto, prop = key.split(".", 1)
|
||||||
qto = IfcAttributeExtractor.get_element_qto(element, qto_name)
|
qto = IfcAttributeSetter.get_element_qto(element, qto_name)
|
||||||
if qto:
|
if qto:
|
||||||
IfcAttributeExtractor.set_qto_property(qto, prop, value)
|
IfcAttributeSetter.set_qto_property(qto, prop, value)
|
||||||
return element
|
return element
|
||||||
pset_name, prop = key.split(".", 1)
|
pset_name, prop = key.split(".", 1)
|
||||||
pset = IfcAttributeExtractor.get_element_pset(element, pset_name)
|
pset = IfcAttributeSetter.get_element_pset(element, pset_name)
|
||||||
if pset:
|
if pset:
|
||||||
IfcAttributeExtractor.set_pset_property(pset, prop, value)
|
IfcAttributeSetter.set_pset_property(pset, prop, value)
|
||||||
return element
|
return element
|
||||||
return element
|
return element
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ class IfcCsv:
|
|||||||
for i, value in enumerate(row):
|
for i, value in enumerate(row):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
continue # Skip GlobalId
|
continue # Skip GlobalId
|
||||||
element = IfcAttributeExtractor.set_element_key(ifc_file, element, headers[i], value)
|
element = IfcAttributeSetter.set_element_key(ifc_file, element, headers[i], value)
|
||||||
ifc_file.write(ifc)
|
ifc_file.write(ifc)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,11 @@ def get_material(element):
|
|||||||
return relationship.RelatingMaterial
|
return relationship.RelatingMaterial
|
||||||
|
|
||||||
|
|
||||||
|
def get_container(element):
|
||||||
|
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
|
||||||
|
return element.ContainedInStructure[0].RelatingStructure
|
||||||
|
|
||||||
|
|
||||||
def replace_attribute(element, old, new):
|
def replace_attribute(element, old, new):
|
||||||
for i, attribute in enumerate(element):
|
for i, attribute in enumerate(element):
|
||||||
if attribute == old:
|
if attribute == old:
|
||||||
|
|||||||
@@ -227,6 +227,14 @@ class Selector:
|
|||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
key = ".".join(key.split(".")[1:])
|
key = ".".join(key.split(".")[1:])
|
||||||
|
elif "." in key and key.split(".")[0] == "container":
|
||||||
|
try:
|
||||||
|
element = ifcopenshell.util.element.get_container(element)
|
||||||
|
if not element:
|
||||||
|
return None
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
key = ".".join(key.split(".")[1:])
|
||||||
info = element.get_info()
|
info = element.get_info()
|
||||||
if key in info:
|
if key in info:
|
||||||
return info[key]
|
return info[key]
|
||||||
|
|||||||
Reference in New Issue
Block a user