bim.add_drawing_to_sheet - poll message

This commit is contained in:
Andrej730
2024-09-02 16:57:46 +05:00
parent 3c333c6b59
commit 11068fe338
2 changed files with 19 additions and 2 deletions
@@ -1481,11 +1481,19 @@ class AddDrawingToSheet(bpy.types.Operator, tool.Ifc.Operator):
@classmethod
def poll(cls, context):
props = context.scene.DocProperties
return props.drawings and props.sheets and context.scene.BIMProperties.data_dir
# Won't be visible in UI anyway.
if not props.sheets or not context.scene.BIMProperties.data_dir:
return False
if not tool.Drawing.get_active_drawing_item():
cls.poll_message_set("No drawing selected.")
return False
return True
def _execute(self, context):
props = context.scene.DocProperties
active_drawing = props.drawings[props.active_drawing_index]
active_drawing = tool.Drawing.get_active_drawing_item()
assert active_drawing
active_sheet = tool.Drawing.get_active_sheet(context)
drawing = tool.Ifc.get().by_id(active_drawing.ifc_definition_id)
drawing_reference = tool.Drawing.get_drawing_document(drawing)
+9
View File
@@ -847,6 +847,15 @@ class Drawing(bonsai.core.tool.Drawing):
props = context.scene.DocProperties
return next(s for s in props.sheets[: props.active_sheet_index + 1][::-1] if s.is_sheet)
@classmethod
def get_active_drawing_item(cls) -> Union[bpy.types.PropertyGroup, None]:
props = bpy.context.scene.DocProperties
drawing_index = props.active_drawing_index
if len(props.drawings) > drawing_index >= 0:
item = props.drawings[drawing_index]
if item.is_drawing:
return item
@classmethod
def import_text_attributes(cls, obj: bpy.types.Object) -> None:
from bonsai.bim.module.drawing.prop import BOX_ALIGNMENT_POSITIONS