A bit more intuitive adding drawing/schedule to the sheet

Now it will detect currently active sheet even if you have sheet's drawing/titleblock/schedule selected.
This commit is contained in:
Andrej730
2023-05-03 15:38:51 +05:00
parent 60a9d96ac8
commit 2001119dff
2 changed files with 7 additions and 2 deletions
@@ -1034,7 +1034,7 @@ class AddDrawingToSheet(bpy.types.Operator, Operator):
def _execute(self, context):
props = context.scene.DocProperties
active_drawing = props.drawings[props.active_drawing_index]
active_sheet = props.sheets[props.active_sheet_index]
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)
@@ -1574,7 +1574,7 @@ class AddScheduleToSheet(bpy.types.Operator, Operator):
def _execute(self, context):
props = context.scene.DocProperties
active_schedule = props.schedules[props.active_schedule_index]
active_sheet = props.sheets[props.active_sheet_index]
active_sheet = tool.Drawing.get_active_sheet(context)
schedule = tool.Ifc.get().by_id(active_schedule.ifc_definition_id)
if tool.Ifc.get_schema() == "IFC2X3":
schedule_location = tool.Drawing.get_path_with_ext(schedule.DocumentReferences[0].Location, "svg")
@@ -671,6 +671,11 @@ class Drawing(blenderbim.core.tool.Drawing):
new.name = os.path.basename(reference.Location)
new.reference_type = reference.Description
@classmethod
def get_active_sheet(cls, context):
props = context.scene.DocProperties
return next(s for s in props.sheets[: props.active_sheet_index + 1][::-1] if s.is_sheet)
@classmethod
def import_text_attributes(cls, obj):
props = obj.BIMTextProperties