reveal element filters and drawing underlay panels just if drawing is active

Those two panels were requiring drawing's camera to be active object which was a bit confusing since "Active Drawing" section above worked fine without selecting camera explicitly.

https://i.imgur.com/wcmA73Z.png
This commit is contained in:
Andrej730
2024-08-27 17:49:59 +05:00
parent 5e95985d19
commit 8309b13db0
2 changed files with 8 additions and 13 deletions
@@ -1779,7 +1779,7 @@ class SaveDrawingStyle(bpy.types.Operator, tool.Ifc.Operator):
if self.index:
index = int(self.index)
else:
index = context.active_object.data.BIMCameraProperties.active_drawing_style_index
index = context.scene.camera.data.BIMCameraProperties.active_drawing_style_index
scene.DocProperties.drawing_styles[index].raster_style = json.dumps(style)
bpy.ops.bim.save_drawing_styles_data()
@@ -2678,8 +2678,9 @@ class EditElementFilter(bpy.types.Operator, tool.Ifc.Operator):
filter_mode: bpy.props.StringProperty()
def _execute(self, context):
props = context.active_object.data.BIMCameraProperties
obj = bpy.context.scene.camera
assert obj
props = obj.data.BIMCameraProperties
element = tool.Ifc.get_entity(obj)
pset = tool.Pset.get_element_pset(element, "EPset_Drawing")
if self.filter_mode == "INCLUDE":
+5 -11
View File
@@ -106,11 +106,7 @@ class BIM_PT_element_filters(Panel):
@classmethod
def poll(cls, context):
return (
context.scene.camera
and context.active_object
and hasattr(context.active_object.data, "BIMCameraProperties")
)
return bool((camera := context.scene.camera) and tool.Ifc.get_entity(camera))
def draw(self, context):
if not ElementFiltersData.is_loaded:
@@ -160,17 +156,15 @@ class BIM_PT_drawing_underlay(Panel):
@classmethod
def poll(cls, context):
return (
context.scene.camera
and context.active_object
and hasattr(context.active_object.data, "BIMCameraProperties")
)
return bool((camera := context.scene.camera) and tool.Ifc.get_entity(camera))
def draw(self, context):
layout = self.layout
layout.use_property_split = True
camera = context.scene.camera
assert camera
dprops = context.scene.DocProperties
props = context.active_object.data.BIMCameraProperties
props = camera.data.BIMCameraProperties
drawing_index_is_valid = props.active_drawing_style_index < len(dprops.drawing_styles)
if not DrawingsData.is_loaded: