mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Redo mechanism that allows filtered BIM Tool classes to be less "magic" and more explicit whether it filters all vs a specific element type.
This commit is contained in:
@@ -41,14 +41,16 @@ class AuthoringData:
|
||||
data = {}
|
||||
type_thumbnails = {}
|
||||
types_per_page = 9
|
||||
ifc_element_type = None
|
||||
is_loaded = False
|
||||
|
||||
@classmethod
|
||||
def load(cls, ifc_element_type=False):
|
||||
def load(cls, ifc_element_type=None):
|
||||
cls.is_loaded = True
|
||||
cls.props = bpy.context.scene.BIMModelProperties
|
||||
if ifc_element_type is not False:
|
||||
cls.data["ifc_element_type"] = ifc_element_type
|
||||
if ifc_element_type:
|
||||
cls.ifc_element_type = None if ifc_element_type == "all" else ifc_element_type
|
||||
cls.data["ifc_element_type"] = cls.ifc_element_type
|
||||
cls.data["ifc_classes"] = cls.ifc_classes()
|
||||
cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes()
|
||||
cls.data["type_class"] = cls.type_class()
|
||||
|
||||
@@ -123,19 +123,18 @@ class AddConstrTypeInstance(bpy.types.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMModelProperties
|
||||
ifc_class = self.ifc_class or props.ifc_class
|
||||
relating_type_id = self.relating_type_id or props.relating_type_id
|
||||
|
||||
if not ifc_class or not relating_type_id:
|
||||
if not relating_type_id:
|
||||
return {"FINISHED"}
|
||||
|
||||
if self.from_invoke:
|
||||
props.ifc_class = self.ifc_class
|
||||
props.relating_type_id = str(self.relating_type_id)
|
||||
|
||||
self.file = IfcStore.get_file()
|
||||
instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, self.file.schema)[0]
|
||||
relating_type = self.file.by_id(int(relating_type_id))
|
||||
ifc_class = relating_type.is_a()
|
||||
instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, self.file.schema)[0]
|
||||
material = ifcopenshell.util.element.get_material(relating_type)
|
||||
|
||||
if material and material.is_a("IfcMaterialProfileSet"):
|
||||
|
||||
@@ -66,7 +66,7 @@ class BimTool(WorkSpaceTool):
|
||||
|
||||
def draw_settings(context, layout, ws_tool):
|
||||
# Unlike operators, Blender doesn't treat workspace tools as a class, so we'll create our own.
|
||||
BimToolUI.draw(context, layout)
|
||||
BimToolUI.draw(context, layout, ifc_element_type="all")
|
||||
|
||||
|
||||
class WallTool(BimTool):
|
||||
@@ -203,6 +203,8 @@ class BimToolUI:
|
||||
|
||||
if not AuthoringData.is_loaded:
|
||||
AuthoringData.load(ifc_element_type)
|
||||
elif ifc_element_type == "all" and AuthoringData.data["ifc_element_type"] is not None:
|
||||
AuthoringData.load("all")
|
||||
elif AuthoringData.data["ifc_element_type"] != ifc_element_type:
|
||||
AuthoringData.load(ifc_element_type)
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class SpatialToolUI:
|
||||
# SpatialData.load()
|
||||
|
||||
if not AuthoringData.is_loaded:
|
||||
AuthoringData.load(None)
|
||||
AuthoringData.load()
|
||||
|
||||
cls.draw_type_selection_interface(context)
|
||||
cls.draw_default_interface(context)
|
||||
|
||||
Reference in New Issue
Block a user