Allow people to export context / project metadata

This commit is contained in:
Dion Moult
2020-04-06 10:18:23 +10:00
parent 1662b11fb2
commit 96ab539a0f
5 changed files with 123 additions and 2 deletions
@@ -572,6 +572,9 @@ class IfcParser():
{'rel_aggregates_relating_object': obj}
)
self.selected_products.append({'raw': obj, 'metadata': metadata})
elif self.is_a_project(self.get_ifc_class(obj.name)) \
or self.is_a_library(self.get_ifc_class(obj.name)):
pass
elif not self.is_a_library(self.get_ifc_class(obj.users_collection[0].name)):
self.selected_products.append({'raw': obj, 'metadata': metadata})
@@ -695,11 +698,12 @@ class IfcParser():
def get_project(self):
for collection in bpy.data.collections:
if self.is_a_project(self.get_ifc_class(collection.name)):
obj = bpy.data.objects.get(collection.name)
return {
'ifc': None,
'raw': collection,
'class': self.get_ifc_class(collection.name),
'attributes': self.get_object_attributes(collection)
'attributes': self.get_object_attributes(obj)
}
def get_libraries(self):
@@ -598,6 +598,7 @@ class QuickProjectSetup(bpy.types.Operator):
building = bpy.data.collections.new('IfcBuilding/My Building')
building_storey = bpy.data.collections.new('IfcBuildingStorey/Ground Floor')
project_obj = bpy.data.objects.new('IfcProject/My Project', None)
site_obj = bpy.data.objects.new('IfcSite/My Site', None)
building_obj = bpy.data.objects.new('IfcBuilding/My Building', None)
building_storey_obj = bpy.data.objects.new('IfcBuildingStorey/Ground Floor', None)
@@ -607,6 +608,7 @@ class QuickProjectSetup(bpy.types.Operator):
site.children.link(building)
building.children.link(building_storey)
project.objects.link(project_obj)
site.objects.link(site_obj)
building.objects.link(building_obj)
building_storey.objects.link(building_storey_obj)
+1 -1
View File
@@ -119,7 +119,7 @@ def getIfcProducts(self, context):
global products_enum
if len(products_enum) < 1:
products_enum.extend([(e, e, '') for e in
['IfcElement', 'IfcElementType', 'IfcSpatialElement', 'IfcStructural']])
['IfcElement', 'IfcElementType', 'IfcSpatialElement', 'IfcStructural', 'IfcContext']])
return products_enum
@@ -10,6 +10,7 @@ class IfcSchema():
self.schema_dir = os.path.join(cwd, 'schema') # TODO: make configurable
# TODO: Make it less troublesome
self.products = [
'IfcContext',
'IfcElement',
'IfcSpatialElement',
'IfcStructural',
@@ -0,0 +1,114 @@
{
"IfcProject": {
"is_abstract": false,
"parent": "IfcContext",
"attributes": [
{
"name": "GlobalId",
"type": "IfcGloballyUniqueId",
"is_enum": false,
"enum_values": []
},
{
"name": "Name",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
},
{
"name": "Description",
"type": "IfcText",
"is_enum": false,
"enum_values": []
},
{
"name": "ObjectType",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
},
{
"name": "LongName",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
},
{
"name": "Phase",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
}
],
"complex_attributes": [
{
"name": "OwnerHistory",
"type": "IfcOwnerHistory",
"is_select": false,
"select_types": []
},
{
"name": "UnitsInContext",
"type": "IfcUnitAssignment",
"is_select": false,
"select_types": []
}
]
},
"IfcProjectLibrary": {
"is_abstract": false,
"parent": "IfcContext",
"attributes": [
{
"name": "GlobalId",
"type": "IfcGloballyUniqueId",
"is_enum": false,
"enum_values": []
},
{
"name": "Name",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
},
{
"name": "Description",
"type": "IfcText",
"is_enum": false,
"enum_values": []
},
{
"name": "ObjectType",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
},
{
"name": "LongName",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
},
{
"name": "Phase",
"type": "IfcLabel",
"is_enum": false,
"enum_values": []
}
],
"complex_attributes": [
{
"name": "OwnerHistory",
"type": "IfcOwnerHistory",
"is_select": false,
"select_types": []
},
{
"name": "UnitsInContext",
"type": "IfcUnitAssignment",
"is_select": false,
"select_types": []
}
]
}
}