mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Exporting now uses custom people and organisations defined from the UI. See #875.
This commit is contained in:
@@ -65,10 +65,14 @@ if bpy is not None:
|
|||||||
operator.RemoveObjectConstraint,
|
operator.RemoveObjectConstraint,
|
||||||
operator.AddPerson,
|
operator.AddPerson,
|
||||||
operator.RemovePerson,
|
operator.RemovePerson,
|
||||||
|
operator.AddPersonRole,
|
||||||
|
operator.RemovePersonRole,
|
||||||
operator.AddPersonAddress,
|
operator.AddPersonAddress,
|
||||||
operator.RemovePersonAddress,
|
operator.RemovePersonAddress,
|
||||||
operator.AddOrganisation,
|
operator.AddOrganisation,
|
||||||
operator.RemoveOrganisation,
|
operator.RemoveOrganisation,
|
||||||
|
operator.AddOrganisationRole,
|
||||||
|
operator.RemoveOrganisationRole,
|
||||||
operator.AddOrganisationAddress,
|
operator.AddOrganisationAddress,
|
||||||
operator.RemoveOrganisationAddress,
|
operator.RemoveOrganisationAddress,
|
||||||
operator.AddDocumentInformation,
|
operator.AddDocumentInformation,
|
||||||
@@ -158,6 +162,7 @@ if bpy is not None:
|
|||||||
operator.ConvertLocalToGlobal,
|
operator.ConvertLocalToGlobal,
|
||||||
prop.StrProperty,
|
prop.StrProperty,
|
||||||
prop.Variable,
|
prop.Variable,
|
||||||
|
prop.Role,
|
||||||
prop.Address,
|
prop.Address,
|
||||||
prop.Person,
|
prop.Person,
|
||||||
prop.Organisation,
|
prop.Organisation,
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"Name": "IfcOpenShell",
|
|
||||||
"Description": "IfcOpenShell is an open source (LGPL) software library that helps users and software developers to work with the IFC file format.",
|
|
||||||
"Roles": [{
|
|
||||||
"Role": "USERDEFINED",
|
|
||||||
"UserDefinedRole": "CONTRIBUTOR"
|
|
||||||
}],
|
|
||||||
"Addresses": [
|
|
||||||
{
|
|
||||||
"Purpose": "USERDEFINED",
|
|
||||||
"UserDefinedPurpose": "WEBPAGE",
|
|
||||||
"Description": "The main webpage of the software collection.",
|
|
||||||
"WWWHomePageURL": "https://ifcopenshell.org"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Purpose": "USERDEFINED",
|
|
||||||
"UserDefinedPurpose": "WEBPAGE",
|
|
||||||
"Description": "The BlenderBIM webpage of the software collection.",
|
|
||||||
"WWWHomePageURL": "https://blenderbim.org"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Purpose": "USERDEFINED",
|
|
||||||
"UserDefinedPurpose": "REPOSITORY",
|
|
||||||
"Description": "The source code repository of the software collection.",
|
|
||||||
"WWWHomePageURL": "https://github.com/IfcOpenShell/IfcOpenShell.git"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"Identification": "Moult",
|
|
||||||
"FamilyName": "Moult",
|
|
||||||
"GivenName": "Dion",
|
|
||||||
"MiddleNames": ["Sebastian", "Isan", "Tan"],
|
|
||||||
"PrefixTitles": ["Mr"],
|
|
||||||
"SuffixTitles": ["UE"],
|
|
||||||
"Roles": [{
|
|
||||||
"Role": "ARCHITECT",
|
|
||||||
"UserDefinedRole": null,
|
|
||||||
"Description": "Draws the pretty pictures"
|
|
||||||
}],
|
|
||||||
"Addresses": [{
|
|
||||||
"Purpose": "OFFICE",
|
|
||||||
"Description": "Headquarters",
|
|
||||||
"UserDefinedPurpose": null,
|
|
||||||
"InternalLocation": "Cupboard under the stairs",
|
|
||||||
"AddressLines": [ "221B Baker Street" ],
|
|
||||||
"PostalBox": null,
|
|
||||||
"Town": "MyTown",
|
|
||||||
"Region": "Middle-Earth",
|
|
||||||
"PostalCode": "42",
|
|
||||||
"Country": "Narnia"
|
|
||||||
}, {
|
|
||||||
"Purpose": "OFFICE",
|
|
||||||
"Description": "Headquarters",
|
|
||||||
"UserDefinedPurpose": null,
|
|
||||||
"TelephoneNumbers": ["0123456789"],
|
|
||||||
"ElectronicMailAddresses": ["dion@thinkmoult.com"],
|
|
||||||
"WWWHomePageURL": "https://thinkmoult.com",
|
|
||||||
"MessagingIDs": ["irc://irc.freenode.net##architect"]
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -697,12 +697,120 @@ class IfcParser():
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def get_people(self):
|
def get_people(self):
|
||||||
with open(self.data_dir + 'owner/person.json') as file:
|
data_map = {
|
||||||
return [{'raw': p} for p in json.load(file)]
|
'name': 'Identification',
|
||||||
|
'family_name': 'FamilyName',
|
||||||
|
'given_name': 'GivenName',
|
||||||
|
}
|
||||||
|
list_data_map = {
|
||||||
|
'middle_names': 'MiddleNames',
|
||||||
|
'prefix_titles': 'PrefixTitles',
|
||||||
|
'suffix_titles': 'SuffixTitles',
|
||||||
|
}
|
||||||
|
results = []
|
||||||
|
for person in bpy.context.scene.BIMProperties.people:
|
||||||
|
attributes = {}
|
||||||
|
for key, value in data_map.items():
|
||||||
|
if getattr(person, key):
|
||||||
|
attributes[value] = getattr(person, key)
|
||||||
|
for key, value in list_data_map.items():
|
||||||
|
if getattr(person, key):
|
||||||
|
attributes[value] = getattr(person, key).split(',')
|
||||||
|
results.append({
|
||||||
|
'ifc': None,
|
||||||
|
'raw': person,
|
||||||
|
'attributes': attributes,
|
||||||
|
'roles': self.get_roles(person.roles),
|
||||||
|
'addresses': self.get_addresses(person.addresses)
|
||||||
|
})
|
||||||
|
return results
|
||||||
|
|
||||||
def get_organisations(self):
|
def get_organisations(self):
|
||||||
with open(self.data_dir + 'owner/organisation.json') as file:
|
data_map = {
|
||||||
return [{'raw': o} for o in json.load(file)]
|
'name': 'Name',
|
||||||
|
'description': 'Description',
|
||||||
|
}
|
||||||
|
results = []
|
||||||
|
for organisation in bpy.context.scene.BIMProperties.organisations:
|
||||||
|
attributes = {}
|
||||||
|
for key, value in data_map.items():
|
||||||
|
if getattr(organisation, key):
|
||||||
|
attributes[value] = getattr(organisation, key)
|
||||||
|
results.append({
|
||||||
|
'ifc': None,
|
||||||
|
'raw': organisation,
|
||||||
|
'attributes': attributes,
|
||||||
|
'roles': self.get_roles(organisation.roles),
|
||||||
|
'addresses': self.get_addresses(organisation.addresses)
|
||||||
|
})
|
||||||
|
return results
|
||||||
|
|
||||||
|
def get_roles(self, roles):
|
||||||
|
data_map = {
|
||||||
|
'name': 'Role',
|
||||||
|
'user_defined_role': 'UserDefinedRole',
|
||||||
|
'description': 'Description',
|
||||||
|
}
|
||||||
|
results = []
|
||||||
|
for role in roles:
|
||||||
|
attributes = {}
|
||||||
|
for key, value in data_map.items():
|
||||||
|
if getattr(role, key):
|
||||||
|
attributes[value] = getattr(role, key)
|
||||||
|
results.append({
|
||||||
|
'ifc': None,
|
||||||
|
'raw': role,
|
||||||
|
'attributes': attributes
|
||||||
|
})
|
||||||
|
return results
|
||||||
|
|
||||||
|
def get_addresses(self, addresses):
|
||||||
|
results = []
|
||||||
|
address_data_map = {
|
||||||
|
'purpose': 'Purpose',
|
||||||
|
'description': 'Description',
|
||||||
|
'user_defined_purpose': 'UserDefinedPurpose',
|
||||||
|
}
|
||||||
|
postal_data_map = {
|
||||||
|
'internal_location': 'InternalLocation',
|
||||||
|
'postal_box': 'PostalBox',
|
||||||
|
'town': 'Town',
|
||||||
|
'region': 'Region',
|
||||||
|
'postal_code': 'PostalCode',
|
||||||
|
'country': 'Country',
|
||||||
|
}
|
||||||
|
telecom_data_map = {
|
||||||
|
'pager_number': 'PagerNumber',
|
||||||
|
'www_home_page_url': 'WWWHomePageURL',
|
||||||
|
}
|
||||||
|
telecom_list_data_map = {
|
||||||
|
'telephone_numbers': 'TelephoneNumbers',
|
||||||
|
'fascimile_numbers': 'FascimileNumbers',
|
||||||
|
'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():
|
||||||
|
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
|
||||||
|
|
||||||
def get_document_references(self):
|
def get_document_references(self):
|
||||||
results = {}
|
results = {}
|
||||||
@@ -1221,15 +1329,55 @@ class IfcExporter():
|
|||||||
self.file.wrapped_data.header.file_name.time_stamp = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).astimezone().replace(microsecond=0).isoformat()
|
self.file.wrapped_data.header.file_name.time_stamp = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).astimezone().replace(microsecond=0).isoformat()
|
||||||
self.file.wrapped_data.header.file_name.preprocessor_version = 'IfcOpenShell {}'.format(ifcopenshell.version)
|
self.file.wrapped_data.header.file_name.preprocessor_version = 'IfcOpenShell {}'.format(ifcopenshell.version)
|
||||||
self.file.wrapped_data.header.file_name.originating_system = '{} {}'.format(
|
self.file.wrapped_data.header.file_name.originating_system = '{} {}'.format(
|
||||||
self.owner_history.OwningApplication.ApplicationFullName,
|
self.get_application_name(), self.get_application_version())
|
||||||
self.owner_history.OwningApplication.Version,
|
if self.owner_history:
|
||||||
)
|
if self.schema == 'IFC2X3':
|
||||||
if self.schema == 'IFC2X3':
|
self.file.wrapped_data.header.file_name.authorization = self.owner_history.OwningUser.ThePerson.Id
|
||||||
self.file.wrapped_data.header.file_name.authorization = self.owner_history.OwningUser.ThePerson.Id
|
else:
|
||||||
|
self.file.wrapped_data.header.file_name.authorization = self.owner_history.OwningUser.ThePerson.Identification
|
||||||
else:
|
else:
|
||||||
self.file.wrapped_data.header.file_name.authorization = self.owner_history.OwningUser.ThePerson.Identification
|
self.file.wrapped_data.header.file_name.authorization = 'Nobody'
|
||||||
|
|
||||||
|
def get_application_name(self):
|
||||||
|
return 'BlenderBIM'
|
||||||
|
|
||||||
|
def get_application_version(self):
|
||||||
|
return '.'.join([str(x) for x in [addon.bl_info.get('version', (-1,-1,-1)) for addon in addon_utils.modules() if addon.bl_info['name'] == 'BlenderBIM'][0]])
|
||||||
|
|
||||||
|
def get_application_organisation(self):
|
||||||
|
self.application_organisation = self.file.create_entity('IfcOrganization', **{
|
||||||
|
"Name": "IfcOpenShell",
|
||||||
|
"Description": "IfcOpenShell is an open source (LGPL) software library that helps users and software developers to work with the IFC file format.",
|
||||||
|
"Roles": [self.file.create_entity('IfcActorRole', **{
|
||||||
|
"Role": "USERDEFINED",
|
||||||
|
"UserDefinedRole": "CONTRIBUTOR"
|
||||||
|
})],
|
||||||
|
"Addresses": [
|
||||||
|
self.file.create_entity('IfcTelecomAddress', **{
|
||||||
|
"Purpose": "USERDEFINED",
|
||||||
|
"UserDefinedPurpose": "WEBPAGE",
|
||||||
|
"Description": "The main webpage of the software collection.",
|
||||||
|
"WWWHomePageURL": "https://ifcopenshell.org"
|
||||||
|
}),
|
||||||
|
self.file.create_entity('IfcTelecomAddress', **{
|
||||||
|
"Purpose": "USERDEFINED",
|
||||||
|
"UserDefinedPurpose": "WEBPAGE",
|
||||||
|
"Description": "The BlenderBIM Add-on webpage of the software collection.",
|
||||||
|
"WWWHomePageURL": "https://blenderbim.org"
|
||||||
|
}),
|
||||||
|
self.file.create_entity('IfcTelecomAddress', **{
|
||||||
|
"Purpose": "USERDEFINED",
|
||||||
|
"UserDefinedPurpose": "REPOSITORY",
|
||||||
|
"Description": "The source code repository of the software collection.",
|
||||||
|
"WWWHomePageURL": "https://github.com/IfcOpenShell/IfcOpenShell.git"
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
return self.application_organisation
|
||||||
|
|
||||||
def create_owner_history(self):
|
def create_owner_history(self):
|
||||||
|
person = None
|
||||||
|
organisation = None
|
||||||
for person in self.ifc_parser.people:
|
for person in self.ifc_parser.people:
|
||||||
if self.schema == 'IFC2X3' and person['ifc'].Id == bpy.context.scene.BIMProperties.person:
|
if self.schema == 'IFC2X3' and person['ifc'].Id == bpy.context.scene.BIMProperties.person:
|
||||||
break
|
break
|
||||||
@@ -1238,18 +1386,20 @@ class IfcExporter():
|
|||||||
for organisation in self.ifc_parser.organisations:
|
for organisation in self.ifc_parser.organisations:
|
||||||
if organisation['ifc'].Name == bpy.context.scene.BIMProperties.organisation:
|
if organisation['ifc'].Name == bpy.context.scene.BIMProperties.organisation:
|
||||||
break
|
break
|
||||||
|
if not person or not organisation:
|
||||||
|
self.owner_history = None
|
||||||
|
return
|
||||||
person_and_organisation = self.file.create_entity('IfcPersonAndOrganization', **{
|
person_and_organisation = self.file.create_entity('IfcPersonAndOrganization', **{
|
||||||
'ThePerson': person['ifc'],
|
'ThePerson': person['ifc'],
|
||||||
'TheOrganization': organisation['ifc'],
|
'TheOrganization': organisation['ifc'],
|
||||||
'Roles': None # TODO
|
'Roles': None # TODO
|
||||||
})
|
})
|
||||||
version = '.'.join([str(x) for x in [addon.bl_info.get('version', (-1,-1,-1)) for addon in addon_utils.modules() if addon.bl_info['name'] == 'BlenderBIM'][0]])
|
developer_organisation = self.get_application_organisation()
|
||||||
developer_organisation = [o for o in self.ifc_parser.organisations if o['ifc'].Name == 'IfcOpenShell'][0]['ifc']
|
|
||||||
application = self.file.create_entity('IfcApplication', **{
|
application = self.file.create_entity('IfcApplication', **{
|
||||||
'ApplicationDeveloper': developer_organisation,
|
'ApplicationDeveloper': developer_organisation,
|
||||||
'Version': version,
|
'Version': self.get_application_version(),
|
||||||
'ApplicationFullName': 'BlenderBIM',
|
'ApplicationFullName': self.get_application_name(),
|
||||||
'ApplicationIdentifier': 'BlenderBIM'
|
'ApplicationIdentifier': self.get_application_name()
|
||||||
})
|
})
|
||||||
self.owner_history = self.file.create_entity('IfcOwnerHistory', **{
|
self.owner_history = self.file.create_entity('IfcOwnerHistory', **{
|
||||||
'OwningUser': person_and_organisation,
|
'OwningUser': person_and_organisation,
|
||||||
@@ -1317,45 +1467,36 @@ class IfcExporter():
|
|||||||
|
|
||||||
def create_people(self):
|
def create_people(self):
|
||||||
for person in self.ifc_parser.people:
|
for person in self.ifc_parser.people:
|
||||||
data = person['raw'].copy()
|
if person['roles']:
|
||||||
if data['Roles']:
|
person['attributes']['Roles'] = self.create_roles(person['roles'])
|
||||||
data['Roles'] = self.create_roles(data['Roles'])
|
if person['addresses']:
|
||||||
if data['Addresses']:
|
person['attributes']['Addresses'] = self.create_addresses(person['addresses'])
|
||||||
data['Addresses'] = self.create_addresses(data['Addresses'])
|
if self.schema == 'IFC2X3' and 'Identification' in person['attributes']:
|
||||||
if self.schema == 'IFC2X3' and 'Identification' in data:
|
person['attributes']['Id'] = person['attributes']['Identification']
|
||||||
data['Id'] = data['Identification']
|
del person['attributes']['Identification']
|
||||||
del data['Identification']
|
person['ifc'] = self.file.create_entity('IfcPerson', **person['attributes'])
|
||||||
person['ifc'] = self.file.create_entity('IfcPerson', **data)
|
|
||||||
|
|
||||||
def create_organisations(self):
|
def create_organisations(self):
|
||||||
for organisation in self.ifc_parser.organisations:
|
for organisation in self.ifc_parser.organisations:
|
||||||
data = organisation['raw'].copy()
|
if organisation['roles']:
|
||||||
if data['Roles']:
|
organisation['attributes']['Roles'] = self.create_roles(organisation['roles'])
|
||||||
data['Roles'] = self.create_roles(data['Roles'])
|
if organisation['addresses']:
|
||||||
if data['Addresses']:
|
organisation['attributes']['Addresses'] = self.create_addresses(organisation['addresses'])
|
||||||
data['Addresses'] = self.create_addresses(data['Addresses'])
|
organisation['ifc'] = self.file.create_entity('IfcOrganization', **organisation['attributes'])
|
||||||
organisation['ifc'] = self.file.create_entity('IfcOrganization', **data)
|
|
||||||
|
|
||||||
def create_roles(self, roles):
|
def create_roles(self, roles):
|
||||||
results = []
|
results = []
|
||||||
for role in roles:
|
for role in roles:
|
||||||
results.append(self.file.create_entity('IfcActorRole', **role))
|
results.append(self.file.create_entity('IfcActorRole', **role['attributes']))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def create_addresses(self, addresses):
|
def create_addresses(self, addresses):
|
||||||
results = []
|
results = []
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
is_postal_address = False
|
if self.schema == 'IFC2X3' and 'MessagingIDs' in address['attributes']:
|
||||||
for key in ['InternalLocation', 'AddressLines', 'PostalBox', 'Town',
|
del address['attributes']['MessagingIDs']
|
||||||
'Region', 'PostalCode', 'Country']:
|
results.append(self.file.create_entity('IfcPostalAddress' if
|
||||||
if key in address:
|
address['is_postal'] else 'IfcTelecomAddress', **address['attributes']))
|
||||||
is_postal_address = True
|
|
||||||
if is_postal_address:
|
|
||||||
results.append(self.file.create_entity('IfcPostalAddress', **address))
|
|
||||||
else:
|
|
||||||
if self.schema == 'IFC2X3' and 'MessagingIDs' in address:
|
|
||||||
del address['MessagingIDs']
|
|
||||||
results.append(self.file.create_entity('IfcTelecomAddress', **address))
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def create_library_information(self):
|
def create_library_information(self):
|
||||||
|
|||||||
@@ -917,6 +917,25 @@ class RemovePersonAddress(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class AddPersonRole(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.add_person_role'
|
||||||
|
bl_label = 'Add Person Role'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
new = bpy.context.scene.BIMProperties.people[bpy.context.scene.BIMProperties.active_person_index].roles.add()
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class RemovePersonRole(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.remove_person_role'
|
||||||
|
bl_label = 'Remove Person Role'
|
||||||
|
index: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.context.scene.BIMProperties.people[bpy.context.scene.BIMProperties.active_person_index].roles.remove(self.index)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AddOrganisation(bpy.types.Operator):
|
class AddOrganisation(bpy.types.Operator):
|
||||||
bl_idname = 'bim.add_organisation'
|
bl_idname = 'bim.add_organisation'
|
||||||
bl_label = 'Add Organisation'
|
bl_label = 'Add Organisation'
|
||||||
@@ -957,6 +976,25 @@ class RemoveOrganisationAddress(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class AddOrganisationRole(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.add_organisation_role'
|
||||||
|
bl_label = 'Add Organisation Role'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
new = bpy.context.scene.BIMProperties.organisations[bpy.context.scene.BIMProperties.active_organisation_index].roles.add()
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveOrganisationRole(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.remove_organisation_role'
|
||||||
|
bl_label = 'Remove Organisation Role'
|
||||||
|
index: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.context.scene.BIMProperties.organisations[bpy.context.scene.BIMProperties.active_organisation_index].roles.remove(self.index)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AddDocumentInformation(bpy.types.Operator):
|
class AddDocumentInformation(bpy.types.Operator):
|
||||||
bl_idname = 'bim.add_document_information'
|
bl_idname = 'bim.add_document_information'
|
||||||
bl_label = 'Add Document Information'
|
bl_label = 'Add Document Information'
|
||||||
|
|||||||
@@ -152,21 +152,15 @@ def getProfileDef(self, context):
|
|||||||
|
|
||||||
def getPersons(self, context):
|
def getPersons(self, context):
|
||||||
global persons_enum
|
global persons_enum
|
||||||
if len(persons_enum) < 1:
|
persons_enum.clear()
|
||||||
persons_enum.clear()
|
persons_enum.extend([(p.name, p.name, '') for p in bpy.context.scene.BIMProperties.people])
|
||||||
with open(os.path.join(self.data_dir, 'owner', 'person.json'), 'r') as f:
|
|
||||||
persons = json.load(f)
|
|
||||||
persons_enum.extend([(p['Identification'], p['Identification'], '') for p in persons])
|
|
||||||
return persons_enum
|
return persons_enum
|
||||||
|
|
||||||
|
|
||||||
def getOrganisations(self, context):
|
def getOrganisations(self, context):
|
||||||
global organisations_enum
|
global organisations_enum
|
||||||
if len(organisations_enum) < 1:
|
organisations_enum.clear()
|
||||||
organisations_enum.clear()
|
organisations_enum.extend([(o.name, o.name, '') for o in bpy.context.scene.BIMProperties.organisations])
|
||||||
with open(os.path.join(self.data_dir, 'owner', 'organisation.json'), 'r') as f:
|
|
||||||
organisations = json.load(f)
|
|
||||||
organisations_enum.extend([(o['Name'], o['Name'], '') for o in organisations])
|
|
||||||
return organisations_enum
|
return organisations_enum
|
||||||
|
|
||||||
|
|
||||||
@@ -832,13 +826,19 @@ class PropertyTemplate(PropertyGroup):
|
|||||||
|
|
||||||
class Address(PropertyGroup):
|
class Address(PropertyGroup):
|
||||||
name: StringProperty(name="Name") # Stores IfcPostalAddress or IfcTelecomAddress
|
name: StringProperty(name="Name") # Stores IfcPostalAddress or IfcTelecomAddress
|
||||||
purpose: StringProperty(name="Purpose")
|
purpose: EnumProperty(items=[
|
||||||
|
('OFFICE', 'OFFICE', 'An office address.'),
|
||||||
|
('SITE', 'SITE', 'A site address.'),
|
||||||
|
('HOME', 'HOME', 'A home address.'),
|
||||||
|
('DISTRIBUTIONPOINT', 'DISTRIBUTIONPOINT', 'A postal distribution point address.'),
|
||||||
|
('USERDEFINED', 'USERDEFINED', 'A user defined address type to be provided.'),
|
||||||
|
], name='Purpose')
|
||||||
description: StringProperty(name="Description")
|
description: StringProperty(name="Description")
|
||||||
user_defined_purpose: StringProperty(name="Custom Purpose")
|
user_defined_purpose: StringProperty(name="Custom Purpose")
|
||||||
|
|
||||||
internal_location: StringProperty(name="Internal Location")
|
internal_location: StringProperty(name="Internal Location")
|
||||||
address_lines: StringProperty(name="Address")
|
address_lines: StringProperty(name="Address")
|
||||||
postal_box: StringProperty(name="PO Box")
|
postal_box: StringProperty(name="Postal Box")
|
||||||
town: StringProperty(name="Town")
|
town: StringProperty(name="Town")
|
||||||
region: StringProperty(name="Region")
|
region: StringProperty(name="Region")
|
||||||
postal_code: StringProperty(name="Postal Code")
|
postal_code: StringProperty(name="Postal Code")
|
||||||
@@ -852,10 +852,41 @@ class Address(PropertyGroup):
|
|||||||
messaging_ids: StringProperty(name="IMs")
|
messaging_ids: StringProperty(name="IMs")
|
||||||
|
|
||||||
|
|
||||||
|
class Role(PropertyGroup):
|
||||||
|
name: EnumProperty(items=[
|
||||||
|
('SUPPLIER', 'SUPPLIER', ''),
|
||||||
|
('MANUFACTURER', 'MANUFACTURER', ''),
|
||||||
|
('CONTRACTOR', 'CONTRACTOR', ''),
|
||||||
|
('SUBCONTRACTOR', 'SUBCONTRACTOR', ''),
|
||||||
|
('ARCHITECT', 'ARCHITECT', ''),
|
||||||
|
('STRUCTURALENGINEER', 'STRUCTURALENGINEER', ''),
|
||||||
|
('COSTENGINEER', 'COSTENGINEER', ''),
|
||||||
|
('CLIENT', 'CLIENT', ''),
|
||||||
|
('BUILDINGOWNER', 'BUILDINGOWNER', ''),
|
||||||
|
('BUILDINGOPERATOR', 'BUILDINGOPERATOR', ''),
|
||||||
|
('MECHANICALENGINEER', 'MECHANICALENGINEER', ''),
|
||||||
|
('ELECTRICALENGINEER', 'ELECTRICALENGINEER', ''),
|
||||||
|
('PROJECTMANAGER', 'PROJECTMANAGER', ''),
|
||||||
|
('FACILITIESMANAGER', 'FACILITIESMANAGER', ''),
|
||||||
|
('CIVILENGINEER', 'CIVILENGINEER', ''),
|
||||||
|
('COMMISSIONINGENGINEER', 'COMMISSIONINGENGINEER', ''),
|
||||||
|
('ENGINEER', 'ENGINEER', ''),
|
||||||
|
('OWNER', 'OWNER', ''),
|
||||||
|
('CONSULTANT', 'CONSULTANT', ''),
|
||||||
|
('CONSTRUCTIONMANAGER', 'CONSTRUCTIONMANAGER', ''),
|
||||||
|
('FIELDCONSTRUCTIONMANAGER', 'FIELDCONSTRUCTIONMANAGER', ''),
|
||||||
|
('RESELLER', 'RESELLER', ''),
|
||||||
|
('USERDEFINED', 'USERDEFINED', ''),
|
||||||
|
], name='Name')
|
||||||
|
user_defined_role: StringProperty(name="Custom Role")
|
||||||
|
description: StringProperty(name="Description")
|
||||||
|
|
||||||
|
|
||||||
class Organisation(PropertyGroup):
|
class Organisation(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
description: StringProperty(name="Description")
|
description: StringProperty(name="Description")
|
||||||
roles: StringProperty(name="Roles")
|
roles: CollectionProperty(name="Roles", type=Role)
|
||||||
|
active_role_index: bpy.props.IntProperty()
|
||||||
addresses: CollectionProperty(name="Addresses", type=Address)
|
addresses: CollectionProperty(name="Addresses", type=Address)
|
||||||
active_address_index: bpy.props.IntProperty()
|
active_address_index: bpy.props.IntProperty()
|
||||||
|
|
||||||
@@ -867,7 +898,8 @@ class Person(PropertyGroup):
|
|||||||
middle_names: StringProperty(name="Middle Names")
|
middle_names: StringProperty(name="Middle Names")
|
||||||
prefix_titles: StringProperty(name="Prefixes")
|
prefix_titles: StringProperty(name="Prefixes")
|
||||||
suffix_titles: StringProperty(name="Suffixes")
|
suffix_titles: StringProperty(name="Suffixes")
|
||||||
roles: StringProperty(name="Roles")
|
roles: CollectionProperty(name="Roles", type=Role)
|
||||||
|
active_role_index: bpy.props.IntProperty()
|
||||||
addresses: CollectionProperty(name="Addresses", type=Address)
|
addresses: CollectionProperty(name="Addresses", type=Address)
|
||||||
active_address_index: bpy.props.IntProperty()
|
active_address_index: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
|||||||
@@ -854,11 +854,17 @@ class BIM_PT_owner(Panel):
|
|||||||
scene = context.scene
|
scene = context.scene
|
||||||
props = scene.BIMProperties
|
props = scene.BIMProperties
|
||||||
|
|
||||||
row = layout.row()
|
if not props.person:
|
||||||
row.prop(props, 'person')
|
layout.label(text="No people found.")
|
||||||
|
else:
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, 'person')
|
||||||
|
|
||||||
row = layout.row()
|
if not props.organisation:
|
||||||
row.prop(props, 'organisation')
|
layout.label(text="No organisations found.")
|
||||||
|
else:
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(props, 'organisation')
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_people(Panel):
|
class BIM_PT_people(Panel):
|
||||||
@@ -879,7 +885,7 @@ class BIM_PT_people(Panel):
|
|||||||
row.operator('bim.add_person')
|
row.operator('bim.add_person')
|
||||||
|
|
||||||
if props.people:
|
if props.people:
|
||||||
layout.template_list('BIM_UL_topics', '',
|
layout.template_list('BIM_UL_generic', '',
|
||||||
props, 'people', props, 'active_person_index')
|
props, 'people', props, 'active_person_index')
|
||||||
|
|
||||||
if props.active_person_index < len(props.people):
|
if props.active_person_index < len(props.people):
|
||||||
@@ -897,11 +903,9 @@ class BIM_PT_people(Panel):
|
|||||||
row.prop(person, 'prefix_titles')
|
row.prop(person, 'prefix_titles')
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(person, 'suffix_titles')
|
row.prop(person, 'suffix_titles')
|
||||||
row = layout.row()
|
layout.label(text="Roles:")
|
||||||
row.prop(person, 'roles')
|
draw_roles_ui(layout, person, 'person')
|
||||||
|
|
||||||
layout.label(text="Addresses:")
|
layout.label(text="Addresses:")
|
||||||
|
|
||||||
draw_addresses_ui(layout, person, 'person')
|
draw_addresses_ui(layout, person, 'person')
|
||||||
|
|
||||||
|
|
||||||
@@ -923,7 +927,7 @@ class BIM_PT_organisations(Panel):
|
|||||||
row.operator('bim.add_organisation')
|
row.operator('bim.add_organisation')
|
||||||
|
|
||||||
if props.organisations:
|
if props.organisations:
|
||||||
layout.template_list('BIM_UL_topics', '',
|
layout.template_list('BIM_UL_generic', '',
|
||||||
props, 'organisations', props, 'active_organisation_index')
|
props, 'organisations', props, 'active_organisation_index')
|
||||||
|
|
||||||
if props.active_organisation_index < len(props.organisations):
|
if props.active_organisation_index < len(props.organisations):
|
||||||
@@ -933,20 +937,38 @@ class BIM_PT_organisations(Panel):
|
|||||||
row.operator('bim.remove_organisation', icon='X', text='').index = props.active_organisation_index
|
row.operator('bim.remove_organisation', icon='X', text='').index = props.active_organisation_index
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(organisation, 'description')
|
row.prop(organisation, 'description')
|
||||||
row = layout.row()
|
layout.label(text="Roles:")
|
||||||
row.prop(organisation, 'roles')
|
draw_roles_ui(layout, organisation, 'organisation')
|
||||||
|
|
||||||
layout.label(text="Addresses:")
|
layout.label(text="Addresses:")
|
||||||
|
|
||||||
draw_addresses_ui(layout, organisation, 'organisation')
|
draw_addresses_ui(layout, organisation, 'organisation')
|
||||||
|
|
||||||
|
|
||||||
|
def draw_roles_ui(layout, parent, parent_type):
|
||||||
|
row = layout.row()
|
||||||
|
row.operator(f'bim.add_{parent_type}_role')
|
||||||
|
|
||||||
|
if parent.roles:
|
||||||
|
layout.template_list('BIM_UL_generic', '',
|
||||||
|
parent, 'roles', parent, 'active_role_index')
|
||||||
|
|
||||||
|
if parent.active_role_index < len(parent.roles):
|
||||||
|
role = parent.roles[parent.active_role_index]
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(role, 'name')
|
||||||
|
row.operator(f'bim.remove_{parent_type}_role', icon='X', text='').index = parent.active_role_index
|
||||||
|
if role.name == 'USERDEFINED':
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(role, 'user_defined_role')
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(role, 'description')
|
||||||
|
|
||||||
|
|
||||||
def draw_addresses_ui(layout, parent, parent_type):
|
def draw_addresses_ui(layout, parent, parent_type):
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator(f'bim.add_{parent_type}_address')
|
row.operator(f'bim.add_{parent_type}_address')
|
||||||
|
|
||||||
if parent.addresses:
|
if parent.addresses:
|
||||||
layout.template_list('BIM_UL_topics', '',
|
layout.template_list('BIM_UL_generic', '',
|
||||||
parent, 'addresses', parent, 'active_address_index')
|
parent, 'addresses', parent, 'active_address_index')
|
||||||
|
|
||||||
if parent.active_address_index < len(parent.addresses):
|
if parent.active_address_index < len(parent.addresses):
|
||||||
|
|||||||
Reference in New Issue
Block a user