mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
Allow people to configure exportable contexts
This commit is contained in:
@@ -98,6 +98,7 @@ def menu_func_import(self, context):
|
|||||||
def register():
|
def register():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
bpy.app.handlers.load_post.append(prop.setDefaultProperties)
|
||||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
||||||
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
||||||
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties)
|
bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties)
|
||||||
@@ -112,6 +113,7 @@ def register():
|
|||||||
def unregister():
|
def unregister():
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
bpy.utils.unregister_class(cls)
|
bpy.utils.unregister_class(cls)
|
||||||
|
bpy.app.handlers.load_post.remove(prop.setDefaultProperties)
|
||||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
||||||
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
||||||
del(bpy.types.Scene.BIMProperties)
|
del(bpy.types.Scene.BIMProperties)
|
||||||
|
|||||||
@@ -2019,29 +2019,4 @@ class IfcExportSettings:
|
|||||||
'SECTION_VIEW', 'ELEVATION_VIEW', 'USERDEFINED', 'NOTDEFINED']
|
'SECTION_VIEW', 'ELEVATION_VIEW', 'USERDEFINED', 'NOTDEFINED']
|
||||||
self.should_export_all_materials_as_styled_items = False
|
self.should_export_all_materials_as_styled_items = False
|
||||||
self.should_use_presentation_style_assignment = False
|
self.should_use_presentation_style_assignment = False
|
||||||
# TODO make this configurable via UI
|
self.context_tree = []
|
||||||
self.context_tree = self.build_context_tree()
|
|
||||||
|
|
||||||
def build_context_tree(self):
|
|
||||||
tree = []
|
|
||||||
for context in self.contexts:
|
|
||||||
subcontexts = []
|
|
||||||
for subcontext in self.subcontexts + self.generated_subcontexts:
|
|
||||||
target_views = []
|
|
||||||
for target_view in self.target_views:
|
|
||||||
if context == 'Model' \
|
|
||||||
and target_view != 'MODEL_VIEW':
|
|
||||||
continue
|
|
||||||
elif context == 'Plan' \
|
|
||||||
and target_view == 'MODEL_VIEW':
|
|
||||||
continue
|
|
||||||
target_views.append(target_view)
|
|
||||||
subcontexts.append({
|
|
||||||
'name': subcontext,
|
|
||||||
'target_views': target_views
|
|
||||||
})
|
|
||||||
tree.append({
|
|
||||||
'name': context,
|
|
||||||
'subcontexts': subcontexts
|
|
||||||
})
|
|
||||||
return tree
|
|
||||||
|
|||||||
@@ -36,6 +36,19 @@ class ExportIFC(bpy.types.Operator):
|
|||||||
ifc_export_settings.has_representations = bpy.context.scene.BIMProperties.export_has_representations
|
ifc_export_settings.has_representations = bpy.context.scene.BIMProperties.export_has_representations
|
||||||
ifc_export_settings.should_export_all_materials_as_styled_items = bpy.context.scene.BIMProperties.export_should_export_all_materials_as_styled_items
|
ifc_export_settings.should_export_all_materials_as_styled_items = bpy.context.scene.BIMProperties.export_should_export_all_materials_as_styled_items
|
||||||
ifc_export_settings.should_use_presentation_style_assignment = bpy.context.scene.BIMProperties.export_should_use_presentation_style_assignment
|
ifc_export_settings.should_use_presentation_style_assignment = bpy.context.scene.BIMProperties.export_should_use_presentation_style_assignment
|
||||||
|
ifc_export_settings.context_tree = []
|
||||||
|
for context in ['model', 'plan']:
|
||||||
|
if getattr(bpy.context.scene.BIMProperties, 'has_{}_context'.format(context)):
|
||||||
|
subcontexts = {}
|
||||||
|
for subcontext in getattr(bpy.context.scene.BIMProperties, '{}_subcontexts'.format(context)):
|
||||||
|
subcontexts.setdefault(subcontext.name, []).append(subcontext.target_view)
|
||||||
|
ifc_export_settings.context_tree.append({
|
||||||
|
'name': context.title(),
|
||||||
|
'subcontexts': [
|
||||||
|
{ 'name': key, 'target_views': value }
|
||||||
|
for key, value in subcontexts.items()
|
||||||
|
]
|
||||||
|
})
|
||||||
ifc_parser = export_ifc.IfcParser(ifc_export_settings)
|
ifc_parser = export_ifc.IfcParser(ifc_export_settings)
|
||||||
ifc_schema = export_ifc.IfcSchema(ifc_export_settings)
|
ifc_schema = export_ifc.IfcSchema(ifc_export_settings)
|
||||||
qto_calculator = export_ifc.QtoCalculator()
|
qto_calculator = export_ifc.QtoCalculator()
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import os
|
|||||||
import csv
|
import csv
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from . import export_ifc
|
from . import export_ifc
|
||||||
|
import bpy
|
||||||
from bpy.types import PropertyGroup
|
from bpy.types import PropertyGroup
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
from bpy.props import (
|
from bpy.props import (
|
||||||
StringProperty,
|
StringProperty,
|
||||||
EnumProperty,
|
EnumProperty,
|
||||||
@@ -34,6 +36,15 @@ contexts_enum = []
|
|||||||
subcontexts_enum = []
|
subcontexts_enum = []
|
||||||
target_views_enum = []
|
target_views_enum = []
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def setDefaultProperties(scene):
|
||||||
|
if bpy.context.scene.BIMProperties.has_model_context \
|
||||||
|
and len(bpy.context.scene.BIMProperties.model_subcontexts) == 0:
|
||||||
|
subcontext = bpy.context.scene.BIMProperties.model_subcontexts.add()
|
||||||
|
subcontext.name = 'Body'
|
||||||
|
subcontext.target_view = 'MODEL_VIEW'
|
||||||
|
|
||||||
|
|
||||||
def getIfcPredefinedTypes(self, context):
|
def getIfcPredefinedTypes(self, context):
|
||||||
global types_enum
|
global types_enum
|
||||||
if len(types_enum) < 1:
|
if len(types_enum) < 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user