mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 01:31:00 +00:00
Add support for exporting addresses to the site and building
This commit is contained in:
@@ -349,10 +349,10 @@ class IfcParser():
|
|||||||
'ifc': None,
|
'ifc': None,
|
||||||
'raw': obj,
|
'raw': obj,
|
||||||
'class': self.get_ifc_class(obj.name),
|
'class': self.get_ifc_class(obj.name),
|
||||||
|
'attributes': self.get_object_attributes(obj),
|
||||||
'relating_structure': None,
|
'relating_structure': None,
|
||||||
'relating_host': None,
|
'relating_host': None,
|
||||||
'relating_qtos_key': None,
|
'relating_qtos_key': None,
|
||||||
'attributes': self.get_object_attributes(obj),
|
|
||||||
'has_boundary_condition': obj.BIMObjectProperties.has_boundary_condition,
|
'has_boundary_condition': obj.BIMObjectProperties.has_boundary_condition,
|
||||||
'boundary_condition_class': None,
|
'boundary_condition_class': None,
|
||||||
'boundary_condition_attributes': {},
|
'boundary_condition_attributes': {},
|
||||||
@@ -752,6 +752,11 @@ class IfcParser():
|
|||||||
|
|
||||||
def get_addresses(self, addresses):
|
def get_addresses(self, addresses):
|
||||||
results = []
|
results = []
|
||||||
|
for address in addresses:
|
||||||
|
results.append(self.get_address(address))
|
||||||
|
return results
|
||||||
|
|
||||||
|
def get_address(self, address):
|
||||||
address_data_map = {
|
address_data_map = {
|
||||||
'purpose': 'Purpose',
|
'purpose': 'Purpose',
|
||||||
'description': 'Description',
|
'description': 'Description',
|
||||||
@@ -775,28 +780,26 @@ class IfcParser():
|
|||||||
'electronic_mail_addresses': 'ElectronicMailAddresses',
|
'electronic_mail_addresses': 'ElectronicMailAddresses',
|
||||||
'messaging_ids': 'MessagingIDs',
|
'messaging_ids': 'MessagingIDs',
|
||||||
}
|
}
|
||||||
for address in addresses:
|
attributes = {}
|
||||||
attributes = {}
|
if 'IfcPostalAddress' in address.name:
|
||||||
if 'IfcPostalAddress' in address.name:
|
merged_data_map = {**address_data_map, **postal_data_map}
|
||||||
merged_data_map = {**address_data_map, **postal_data_map}
|
if address.address_lines:
|
||||||
if address.address_lines:
|
attributes['AddressLines'] = address.address_lines.split('/')
|
||||||
attributes['AddressLines'] = address.address_lines.split('/')
|
elif 'IfcTelecomAddress' in address.name:
|
||||||
elif 'IfcTelecomAddress' in address.name:
|
merged_data_map = {**address_data_map, **telecom_data_map}
|
||||||
merged_data_map = {**address_data_map, **telecom_data_map}
|
for key, value in telecom_list_data_map.items():
|
||||||
for key, value in telecom_list_data_map.items():
|
|
||||||
if getattr(address, key):
|
|
||||||
attributes[value] = getattr(address, key).split(',')
|
|
||||||
for key, value in merged_data_map.items():
|
|
||||||
if getattr(address, key):
|
if getattr(address, key):
|
||||||
attributes[value] = getattr(address, key)
|
attributes[value] = getattr(address, key).split(',')
|
||||||
results.append({
|
for key, value in merged_data_map.items():
|
||||||
'ifc': None,
|
if getattr(address, key):
|
||||||
'raw': address,
|
attributes[value] = getattr(address, key)
|
||||||
'is_postal': 'IfcPostalAddress' in address.name,
|
return {
|
||||||
'is_telecom': 'IfcTelecomAddress' in address.name,
|
'ifc': None,
|
||||||
'attributes': attributes
|
'raw': address,
|
||||||
})
|
'is_postal': 'IfcPostalAddress' in address.name,
|
||||||
return results
|
'is_telecom': 'IfcTelecomAddress' in address.name,
|
||||||
|
'attributes': attributes
|
||||||
|
}
|
||||||
|
|
||||||
def get_document_references(self):
|
def get_document_references(self):
|
||||||
results = {}
|
results = {}
|
||||||
@@ -954,7 +957,8 @@ class IfcParser():
|
|||||||
'ifc': None,
|
'ifc': None,
|
||||||
'raw': obj,
|
'raw': obj,
|
||||||
'class': self.get_ifc_class(obj.name),
|
'class': self.get_ifc_class(obj.name),
|
||||||
'attributes': self.get_object_attributes(obj)
|
'attributes': self.get_object_attributes(obj),
|
||||||
|
'address': self.get_address(obj.BIMObjectProperties.address)
|
||||||
}
|
}
|
||||||
self.append_product_attributes(element, obj)
|
self.append_product_attributes(element, obj)
|
||||||
self.get_product_psets_qtos(element, obj, is_pset=True)
|
self.get_product_psets_qtos(element, obj, is_pset=True)
|
||||||
@@ -1539,12 +1543,15 @@ class IfcExporter():
|
|||||||
def create_addresses(self, addresses):
|
def create_addresses(self, addresses):
|
||||||
results = []
|
results = []
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
if self.schema == 'IFC2X3' and 'MessagingIDs' in address['attributes']:
|
results.append(self.create_address(address))
|
||||||
del address['attributes']['MessagingIDs']
|
|
||||||
results.append(self.file.create_entity('IfcPostalAddress' if
|
|
||||||
address['is_postal'] else 'IfcTelecomAddress', **address['attributes']))
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def create_address(self, address):
|
||||||
|
if self.schema == 'IFC2X3' and 'MessagingIDs' in address['attributes']:
|
||||||
|
del address['attributes']['MessagingIDs']
|
||||||
|
return self.file.create_entity('IfcPostalAddress' if
|
||||||
|
address['is_postal'] else 'IfcTelecomAddress', **address['attributes'])
|
||||||
|
|
||||||
def create_library_information(self):
|
def create_library_information(self):
|
||||||
information = self.ifc_parser.library_information
|
information = self.ifc_parser.library_information
|
||||||
if not information:
|
if not information:
|
||||||
@@ -1854,6 +1861,12 @@ class IfcExporter():
|
|||||||
'ObjectPlacement': placement,
|
'ObjectPlacement': placement,
|
||||||
'Representation': self.get_product_shape(element)
|
'Representation': self.get_product_shape(element)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if element['class'] == 'IfcSite':
|
||||||
|
element['attributes'].update({'SiteAddress': self.create_address(element['address'])})
|
||||||
|
elif element['class'] == 'IfcBuilding':
|
||||||
|
element['attributes'].update({'BuildingAddress': self.create_address(element['address'])})
|
||||||
|
|
||||||
element['ifc'] = self.file.create_entity(element['class'], **element['attributes'])
|
element['ifc'] = self.file.create_entity(element['class'], **element['attributes'])
|
||||||
related_objects.append(element['ifc'])
|
related_objects.append(element['ifc'])
|
||||||
self.create_spatial_structure_elements(node['children'], element['ifc'])
|
self.create_spatial_structure_elements(node['children'], element['ifc'])
|
||||||
|
|||||||
@@ -1027,7 +1027,7 @@ class PropertyTemplate(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class Address(PropertyGroup):
|
class Address(PropertyGroup):
|
||||||
name: StringProperty(name="Name") # Stores IfcPostalAddress or IfcTelecomAddress
|
name: StringProperty(name="Name", default='IfcPostalAddress') # Stores IfcPostalAddress or IfcTelecomAddress
|
||||||
purpose: EnumProperty(items=[
|
purpose: EnumProperty(items=[
|
||||||
('OFFICE', 'OFFICE', 'An office address.'),
|
('OFFICE', 'OFFICE', 'An office address.'),
|
||||||
('SITE', 'SITE', 'A site address.'),
|
('SITE', 'SITE', 'A site address.'),
|
||||||
@@ -1385,6 +1385,8 @@ class BIMObjectProperties(PropertyGroup):
|
|||||||
boundary_condition: PointerProperty(name='Boundary Condition', type=BoundaryCondition)
|
boundary_condition: PointerProperty(name='Boundary Condition', type=BoundaryCondition)
|
||||||
structural_member_connection: PointerProperty(name='Structural Member Connection', type=bpy.types.Object)
|
structural_member_connection: PointerProperty(name='Structural Member Connection', type=bpy.types.Object)
|
||||||
representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext)
|
representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext)
|
||||||
|
# Address applies to IfcSite's SiteAddress and IfcBuilding's BuildingAddress
|
||||||
|
address: PointerProperty(name='Address', type=Address)
|
||||||
|
|
||||||
|
|
||||||
class BIMDebugProperties(PropertyGroup):
|
class BIMDebugProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ class BIM_PT_object(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, 'attributes')
|
row.prop(props, 'attributes')
|
||||||
|
|
||||||
|
if 'IfcSite/' in context.active_object.name or 'IfcBuilding/' in context.active_object.name:
|
||||||
|
self.draw_addresses_ui()
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, 'relating_type')
|
row.prop(props, 'relating_type')
|
||||||
row.operator('bim.select_similar_type', icon='RESTRICT_SELECT_OFF', text='')
|
row.operator('bim.select_similar_type', icon='RESTRICT_SELECT_OFF', text='')
|
||||||
@@ -72,6 +75,33 @@ class BIM_PT_object(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, 'material_type')
|
row.prop(props, 'material_type')
|
||||||
|
|
||||||
|
def draw_addresses_ui(self):
|
||||||
|
layout = self.layout
|
||||||
|
layout.label(text="Address:")
|
||||||
|
address = bpy.context.active_object.BIMObjectProperties.address
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'purpose')
|
||||||
|
if address.purpose == 'USERDEFINED':
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'user_defined_purpose')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'description')
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'internal_location')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'address_lines')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'postal_box')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'town')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'region')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'postal_code')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(address, 'country')
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_object_psets(Panel):
|
class BIM_PT_object_psets(Panel):
|
||||||
bl_label = 'IFC Object Property Sets'
|
bl_label = 'IFC Object Property Sets'
|
||||||
|
|||||||
Reference in New Issue
Block a user