WIP refactor representation editing into geometry module. See #1222. Some new functionality as a result:

- Representations can now be added to any context, even invalid ones, non-subcontext, or missing target views
 - Switching representations now change all linked data objects
This commit is contained in:
Dion Moult
2021-01-03 19:09:01 +11:00
parent c5ec54ca7f
commit af5350bb9f
15 changed files with 334 additions and 423 deletions
@@ -1,6 +1,5 @@
import blenderbim.bim.ifc
from blenderbim.bim.ifc import IfcStore
is_loaded = False
class Data:
is_loaded = False
@@ -8,7 +7,7 @@ class Data:
@classmethod
def load(cls):
file = blenderbim.bim.ifc.IfcStore.get_file()
file = IfcStore.get_file()
if not file:
return
cls.contexts = {}
@@ -1,22 +1,25 @@
import bpy
import blenderbim.bim.ifc
import blenderbim.bim.module.context.add_context as add_context
import blenderbim.bim.module.context.remove_context as remove_context
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.context.data import Data
class AddSubcontext(bpy.types.Operator):
bl_idname = "bim.add_subcontext"
bl_label = "Add Subcontext"
def execute(self, context):
self.file = blenderbim.bim.ifc.IfcStore.get_file()
usecase = add_context.Usecase(self.file, {
"context": bpy.context.scene.BIMProperties.available_contexts,
"subcontext": bpy.context.scene.BIMProperties.available_subcontexts,
"target_view": bpy.context.scene.BIMProperties.available_target_views,
})
self.file = IfcStore.get_file()
usecase = add_context.Usecase(
self.file,
{
"context": bpy.context.scene.BIMProperties.available_contexts,
"subcontext": bpy.context.scene.BIMProperties.available_subcontexts,
"target_view": bpy.context.scene.BIMProperties.available_target_views,
},
)
result = usecase.execute()
Data.load()
return {"FINISHED"}
@@ -27,11 +30,8 @@ class RemoveSubcontext(bpy.types.Operator):
ifc_definition_id: bpy.props.IntProperty()
def execute(self, context):
self.file = blenderbim.bim.ifc.IfcStore.get_file()
usecase = remove_context.Usecase(self.file, {
"context": self.file.by_id(self.ifc_definition_id)
})
self.file = IfcStore.get_file()
usecase = remove_context.Usecase(self.file, {"context": self.file.by_id(self.ifc_definition_id)})
usecase.execute()
Data.load()
return {"FINISHED"}