mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
black ifcopenshell-python
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
def get_psets(element):
|
||||
psets = {}
|
||||
try:
|
||||
if element.is_a('IfcTypeObject'):
|
||||
if element.is_a("IfcTypeObject"):
|
||||
if element.HasPropertySets:
|
||||
for definition in element.HasPropertySets:
|
||||
psets[definition.Name] = get_property_definition(definition)
|
||||
else:
|
||||
for relationship in element.IsDefinedBy:
|
||||
if relationship.is_a('IfcRelDefinesByProperties'):
|
||||
if relationship.is_a("IfcRelDefinesByProperties"):
|
||||
definition = relationship.RelatingPropertyDefinition
|
||||
psets[definition.Name] = get_property_definition(definition)
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print('failed to load properties: {}'.format(e))
|
||||
|
||||
print("failed to load properties: {}".format(e))
|
||||
traceback.print_exc()
|
||||
return psets
|
||||
|
||||
@@ -20,9 +21,9 @@ def get_psets(element):
|
||||
def get_property_definition(definition):
|
||||
if definition is not None:
|
||||
props = {}
|
||||
if definition.is_a('IfcElementQuantity'):
|
||||
if definition.is_a("IfcElementQuantity"):
|
||||
props.update(get_quantities(definition.Quantities))
|
||||
elif definition.is_a('IfcPropertySet'):
|
||||
elif definition.is_a("IfcPropertySet"):
|
||||
props.update(get_properties(definition.HasProperties))
|
||||
else:
|
||||
# Entity introduced in IFC4
|
||||
@@ -35,7 +36,7 @@ def get_property_definition(definition):
|
||||
def get_quantities(quantities):
|
||||
results = {}
|
||||
for quantity in quantities:
|
||||
if quantity.is_a('IfcPhysicalSimpleQuantity'):
|
||||
if quantity.is_a("IfcPhysicalSimpleQuantity"):
|
||||
results[quantity.Name] = quantity[3]
|
||||
return results
|
||||
|
||||
@@ -43,22 +44,22 @@ def get_quantities(quantities):
|
||||
def get_properties(properties):
|
||||
results = {}
|
||||
for prop in properties:
|
||||
if prop.is_a('IfcPropertySingleValue'):
|
||||
if prop.is_a("IfcPropertySingleValue"):
|
||||
results[prop.Name] = prop.NominalValue.wrappedValue
|
||||
elif prop.is_a('IfcComplexProperty'):
|
||||
elif prop.is_a("IfcComplexProperty"):
|
||||
data = prop.get_info()
|
||||
data['properties'] = get_properties(prop.HasProperties)
|
||||
del(data['HasProperties'])
|
||||
data["properties"] = get_properties(prop.HasProperties)
|
||||
del data["HasProperties"]
|
||||
results[prop.Name] = data
|
||||
return results
|
||||
|
||||
|
||||
def get_type(element):
|
||||
if hasattr(element, 'IsTypedBy') and element.IsTypedBy:
|
||||
if hasattr(element, "IsTypedBy") and element.IsTypedBy:
|
||||
return element.IsTypedBy[0].RelatingType
|
||||
elif hasattr(element, 'IsDefinedBy') and element.IsDefinedBy: # IFC2X3
|
||||
elif hasattr(element, "IsDefinedBy") and element.IsDefinedBy: # IFC2X3
|
||||
for relationship in element.IsDefinedBy:
|
||||
if relationship.is_a('IfcRelDefinesByType'):
|
||||
if relationship.is_a("IfcRelDefinesByType"):
|
||||
return relationship.RelatingType
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user