mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +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,
|
||||
'raw': obj,
|
||||
'class': self.get_ifc_class(obj.name),
|
||||
'attributes': self.get_object_attributes(obj),
|
||||
'relating_structure': None,
|
||||
'relating_host': None,
|
||||
'relating_qtos_key': None,
|
||||
'attributes': self.get_object_attributes(obj),
|
||||
'has_boundary_condition': obj.BIMObjectProperties.has_boundary_condition,
|
||||
'boundary_condition_class': None,
|
||||
'boundary_condition_attributes': {},
|
||||
@@ -752,6 +752,11 @@ class IfcParser():
|
||||
|
||||
def get_addresses(self, addresses):
|
||||
results = []
|
||||
for address in addresses:
|
||||
results.append(self.get_address(address))
|
||||
return results
|
||||
|
||||
def get_address(self, address):
|
||||
address_data_map = {
|
||||
'purpose': 'Purpose',
|
||||
'description': 'Description',
|
||||
@@ -775,28 +780,26 @@ class IfcParser():
|
||||
'electronic_mail_addresses': 'ElectronicMailAddresses',
|
||||
'messaging_ids': 'MessagingIDs',
|
||||
}
|
||||
for address in addresses:
|
||||
attributes = {}
|
||||
if 'IfcPostalAddress' in address.name:
|
||||
merged_data_map = {**address_data_map, **postal_data_map}
|
||||
if address.address_lines:
|
||||
attributes['AddressLines'] = address.address_lines.split('/')
|
||||
elif 'IfcTelecomAddress' in address.name:
|
||||
merged_data_map = {**address_data_map, **telecom_data_map}
|
||||
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():
|
||||
attributes = {}
|
||||
if 'IfcPostalAddress' in address.name:
|
||||
merged_data_map = {**address_data_map, **postal_data_map}
|
||||
if address.address_lines:
|
||||
attributes['AddressLines'] = address.address_lines.split('/')
|
||||
elif 'IfcTelecomAddress' in address.name:
|
||||
merged_data_map = {**address_data_map, **telecom_data_map}
|
||||
for key, value in telecom_list_data_map.items():
|
||||
if getattr(address, key):
|
||||
attributes[value] = getattr(address, key)
|
||||
results.append({
|
||||
'ifc': None,
|
||||
'raw': address,
|
||||
'is_postal': 'IfcPostalAddress' in address.name,
|
||||
'is_telecom': 'IfcTelecomAddress' in address.name,
|
||||
'attributes': attributes
|
||||
})
|
||||
return results
|
||||
attributes[value] = getattr(address, key).split(',')
|
||||
for key, value in merged_data_map.items():
|
||||
if getattr(address, key):
|
||||
attributes[value] = getattr(address, key)
|
||||
return {
|
||||
'ifc': None,
|
||||
'raw': address,
|
||||
'is_postal': 'IfcPostalAddress' in address.name,
|
||||
'is_telecom': 'IfcTelecomAddress' in address.name,
|
||||
'attributes': attributes
|
||||
}
|
||||
|
||||
def get_document_references(self):
|
||||
results = {}
|
||||
@@ -954,7 +957,8 @@ class IfcParser():
|
||||
'ifc': None,
|
||||
'raw': obj,
|
||||
'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.get_product_psets_qtos(element, obj, is_pset=True)
|
||||
@@ -1539,12 +1543,15 @@ class IfcExporter():
|
||||
def create_addresses(self, addresses):
|
||||
results = []
|
||||
for address in addresses:
|
||||
if self.schema == 'IFC2X3' and 'MessagingIDs' in address['attributes']:
|
||||
del address['attributes']['MessagingIDs']
|
||||
results.append(self.file.create_entity('IfcPostalAddress' if
|
||||
address['is_postal'] else 'IfcTelecomAddress', **address['attributes']))
|
||||
results.append(self.create_address(address))
|
||||
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):
|
||||
information = self.ifc_parser.library_information
|
||||
if not information:
|
||||
@@ -1854,6 +1861,12 @@ class IfcExporter():
|
||||
'ObjectPlacement': placement,
|
||||
'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'])
|
||||
related_objects.append(element['ifc'])
|
||||
self.create_spatial_structure_elements(node['children'], element['ifc'])
|
||||
|
||||
@@ -1027,7 +1027,7 @@ class PropertyTemplate(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=[
|
||||
('OFFICE', 'OFFICE', 'An office address.'),
|
||||
('SITE', 'SITE', 'A site address.'),
|
||||
@@ -1385,6 +1385,8 @@ class BIMObjectProperties(PropertyGroup):
|
||||
boundary_condition: PointerProperty(name='Boundary Condition', type=BoundaryCondition)
|
||||
structural_member_connection: PointerProperty(name='Structural Member Connection', type=bpy.types.Object)
|
||||
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):
|
||||
|
||||
@@ -63,6 +63,9 @@ class BIM_PT_object(Panel):
|
||||
row = layout.row()
|
||||
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.prop(props, 'relating_type')
|
||||
row.operator('bim.select_similar_type', icon='RESTRICT_SELECT_OFF', text='')
|
||||
@@ -72,6 +75,33 @@ class BIM_PT_object(Panel):
|
||||
row = layout.row()
|
||||
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):
|
||||
bl_label = 'IFC Object Property Sets'
|
||||
|
||||
Reference in New Issue
Block a user