mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 14:22:33 +00:00
You can now select all COBie defined assets and types using the selector
This commit is contained in:
@@ -5,6 +5,61 @@ import lark
|
|||||||
class Selector():
|
class Selector():
|
||||||
def parse(self, ifc_file, query):
|
def parse(self, ifc_file, query):
|
||||||
self.file = ifc_file
|
self.file = ifc_file
|
||||||
|
self.cobie_type_assets = [
|
||||||
|
'IfcDoorStyle',
|
||||||
|
'IfcBuildingElementProxyType',
|
||||||
|
'IfcChimneyType',
|
||||||
|
'IfcCoveringType',
|
||||||
|
'IfcDoorType',
|
||||||
|
'IfcFootingType',
|
||||||
|
'IfcPileType',
|
||||||
|
'IfcRoofType',
|
||||||
|
'IfcShadingDeviceType',
|
||||||
|
'IfcWindowType',
|
||||||
|
'IfcDistributionControlElementType',
|
||||||
|
'IfcDistributionChamberElementType',
|
||||||
|
'IfcEnergyConversionDeviceType',
|
||||||
|
'IfcFlowControllerType',
|
||||||
|
'IfcFlowMovingDeviceType',
|
||||||
|
'IfcFlowStorageDeviceType',
|
||||||
|
'IfcFlowTerminalType',
|
||||||
|
'IfcFlowTreatmentDeviceType',
|
||||||
|
'IfcElementAssemblyType',
|
||||||
|
'IfcBuildingElementPartType',
|
||||||
|
'IfcDiscreteAccessoryType',
|
||||||
|
'IfcMechanicalFastenerType',
|
||||||
|
'IfcReinforcingElementType',
|
||||||
|
'IfcVibrationIsolatorType',
|
||||||
|
'IfcFurnishingElementType',
|
||||||
|
'IfcGeographicElementType',
|
||||||
|
'IfcTransportElementType',
|
||||||
|
'IfcSpatialZoneType',
|
||||||
|
'IfcWindowStyle',
|
||||||
|
]
|
||||||
|
self.cobie_component_assets = [
|
||||||
|
'IfcBuildingElementProxy',
|
||||||
|
'IfcChimney',
|
||||||
|
'IfcCovering',
|
||||||
|
'IfcDoor',
|
||||||
|
'IfcShadingDevice',
|
||||||
|
'IfcWindow',
|
||||||
|
'IfcDistributionControlElement',
|
||||||
|
'IfcDistributionChamberElement',
|
||||||
|
'IfcEnergyConversionDevice',
|
||||||
|
'IfcFlowController',
|
||||||
|
'IfcFlowMovingDevice',
|
||||||
|
'IfcFlowStorageDevice',
|
||||||
|
'IfcFlowTerminal',
|
||||||
|
'IfcFlowTreatmentDevice',
|
||||||
|
'IfcDiscreteAccessory',
|
||||||
|
'IfcTendon',
|
||||||
|
'IfcTendonAnchor',
|
||||||
|
'IfcVibrationIsolator',
|
||||||
|
'IfcFurnishingElement',
|
||||||
|
'IfcGeographicElement',
|
||||||
|
'IfcTransportElement',
|
||||||
|
]
|
||||||
|
|
||||||
l = lark.Lark('''start: query (lfunction query)*
|
l = lark.Lark('''start: query (lfunction query)*
|
||||||
query: selector | group
|
query: selector | group
|
||||||
group: "(" query (lfunction query)* ")"
|
group: "(" query (lfunction query)* ")"
|
||||||
@@ -115,7 +170,22 @@ class Selector():
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def get_class_selector(self, class_selector):
|
def get_class_selector(self, class_selector):
|
||||||
elements = self.file.by_type(class_selector.children[0])
|
if class_selector.children[0] == 'COBie':
|
||||||
|
elements = []
|
||||||
|
for ifc_class in self.cobie_component_assets:
|
||||||
|
try:
|
||||||
|
elements += self.file.by_type(ifc_class)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
elif class_selector.children[0] == 'COBieType':
|
||||||
|
elements = []
|
||||||
|
for ifc_class in self.cobie_type_assets:
|
||||||
|
try:
|
||||||
|
elements += self.file.by_type(ifc_class)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
elements = self.file.by_type(class_selector.children[0])
|
||||||
if len(class_selector.children) > 1 \
|
if len(class_selector.children) > 1 \
|
||||||
and class_selector.children[1].data == 'filter':
|
and class_selector.children[1].data == 'filter':
|
||||||
return self.filter_elements(elements, class_selector.children[1])
|
return self.filter_elements(elements, class_selector.children[1])
|
||||||
|
|||||||
Reference in New Issue
Block a user