mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Reuse get_active_sheet_item
This commit is contained in:
@@ -1726,7 +1726,9 @@ class OpenLayout(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.props = tool.Drawing.get_document_props()
|
self.props = tool.Drawing.get_document_props()
|
||||||
sheet = tool.Ifc.get().by_id(self.props.sheets[self.props.active_sheet_index].ifc_definition_id)
|
sheet_item = tool.Drawing.get_active_sheet_item()
|
||||||
|
assert sheet_item
|
||||||
|
sheet = tool.Ifc.get().by_id(sheet_item.ifc_definition_id)
|
||||||
sheet_builder = sheeter.SheetBuilder()
|
sheet_builder = sheeter.SheetBuilder()
|
||||||
sheet_builder.update_sheet_drawing_sizes(sheet)
|
sheet_builder.update_sheet_drawing_sizes(sheet)
|
||||||
core.open_layout(tool.Drawing, sheet=sheet)
|
core.open_layout(tool.Drawing, sheet=sheet)
|
||||||
@@ -1790,7 +1792,9 @@ class OpenSheet(bpy.types.Operator):
|
|||||||
tool.Ifc.get().by_id(s.ifc_definition_id) for s in self.props.sheets if s.is_sheet and s.is_selected
|
tool.Ifc.get().by_id(s.ifc_definition_id) for s in self.props.sheets if s.is_sheet and s.is_selected
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
sheets = [tool.Ifc.get().by_id(self.props.sheets[self.props.active_sheet_index].ifc_definition_id)]
|
sheet_item = tool.Drawing.get_active_sheet_item()
|
||||||
|
assert sheet_item
|
||||||
|
sheets = [tool.Ifc.get().by_id(sheet_item.ifc_definition_id)]
|
||||||
|
|
||||||
sheet_uris: list[str] = []
|
sheet_uris: list[str] = []
|
||||||
sheets_not_found: list[str] = []
|
sheets_not_found: list[str] = []
|
||||||
@@ -1855,7 +1859,7 @@ class AddDrawingToSheet(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
assert active_drawing
|
assert active_drawing
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
|
||||||
active_sheet = tool.Drawing.get_active_sheet(context)
|
active_sheet = tool.Drawing.get_active_sheet()
|
||||||
drawing = tool.Ifc.get().by_id(active_drawing.ifc_definition_id)
|
drawing = tool.Ifc.get().by_id(active_drawing.ifc_definition_id)
|
||||||
drawing_reference = tool.Drawing.get_drawing_document(drawing)
|
drawing_reference = tool.Drawing.get_drawing_document(drawing)
|
||||||
|
|
||||||
@@ -1969,7 +1973,9 @@ class CreateSheets(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if self.create_all:
|
if self.create_all:
|
||||||
sheets = [tool.Ifc.get().by_id(s.ifc_definition_id) for s in props.sheets if s.is_sheet and s.is_selected]
|
sheets = [tool.Ifc.get().by_id(s.ifc_definition_id) for s in props.sheets if s.is_sheet and s.is_selected]
|
||||||
else:
|
else:
|
||||||
sheets = [tool.Ifc.get().by_id(props.sheets[props.active_sheet_index].ifc_definition_id)]
|
sheet_item = tool.Drawing.get_active_sheet_item()
|
||||||
|
assert sheet_item
|
||||||
|
sheets = [tool.Ifc.get().by_id(sheet_item.ifc_definition_id)]
|
||||||
|
|
||||||
warnings: list[tool.Drawing.SheetWarningType] = []
|
warnings: list[tool.Drawing.SheetWarningType] = []
|
||||||
n_sheets_created = 0
|
n_sheets_created = 0
|
||||||
@@ -2735,7 +2741,7 @@ class AddScheduleToSheet(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
props = tool.Drawing.get_document_props()
|
props = tool.Drawing.get_document_props()
|
||||||
active_schedule = props.schedules[props.active_schedule_index]
|
active_schedule = props.schedules[props.active_schedule_index]
|
||||||
active_sheet = tool.Drawing.get_active_sheet(context)
|
active_sheet = tool.Drawing.get_active_sheet()
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
schedule = tool.Ifc.get().by_id(active_schedule.ifc_definition_id)
|
schedule = tool.Ifc.get().by_id(active_schedule.ifc_definition_id)
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
if tool.Ifc.get_schema() == "IFC2X3":
|
||||||
@@ -2803,7 +2809,7 @@ class AddReferenceToSheet(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
props = tool.Drawing.get_document_props()
|
props = tool.Drawing.get_document_props()
|
||||||
active_reference = props.references[props.active_reference_index]
|
active_reference = props.references[props.active_reference_index]
|
||||||
active_sheet = tool.Drawing.get_active_sheet(context)
|
active_sheet = tool.Drawing.get_active_sheet()
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
extref = tool.Ifc.get().by_id(active_reference.ifc_definition_id)
|
extref = tool.Ifc.get().by_id(active_reference.ifc_definition_id)
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
if tool.Ifc.get_schema() == "IFC2X3":
|
||||||
@@ -3219,8 +3225,9 @@ class EditSheet(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
assert context.window_manager
|
assert context.window_manager
|
||||||
self.props = tool.Drawing.get_document_props()
|
sheet_item = tool.Drawing.get_active_sheet_item()
|
||||||
sheet = tool.Ifc.get().by_id(self.props.sheets[self.props.active_sheet_index].ifc_definition_id)
|
assert sheet_item
|
||||||
|
sheet = tool.Ifc.get().by_id(sheet_item.ifc_definition_id)
|
||||||
if sheet.is_a("IfcDocumentInformation"):
|
if sheet.is_a("IfcDocumentInformation"):
|
||||||
self.document_type = "SHEET"
|
self.document_type = "SHEET"
|
||||||
self.name = sheet.Name
|
self.name = sheet.Name
|
||||||
@@ -3248,15 +3255,17 @@ class EditSheet(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
row.prop(self, "identification", text="Identification")
|
row.prop(self, "identification", text="Identification")
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.props = tool.Drawing.get_document_props()
|
props = tool.Drawing.get_document_props()
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
sheet = tool.Ifc.get().by_id(self.props.sheets[self.props.active_sheet_index].ifc_definition_id)
|
sheet_item = tool.Drawing.get_active_sheet_item()
|
||||||
|
assert sheet_item
|
||||||
|
sheet = tool.Ifc.get().by_id(sheet_item.ifc_definition_id)
|
||||||
if self.document_type == "SHEET":
|
if self.document_type == "SHEET":
|
||||||
core.rename_sheet(tool.Ifc, tool.Drawing, sheet=sheet, identification=self.identification, name=self.name)
|
core.rename_sheet(tool.Ifc, tool.Drawing, sheet=sheet, identification=self.identification, name=self.name)
|
||||||
elif self.document_type == "EMBEDDED":
|
elif self.document_type == "EMBEDDED":
|
||||||
core.rename_reference(tool.Ifc, tool.Drawing, reference=sheet, identification=self.identification)
|
core.rename_reference(tool.Ifc, tool.Drawing, reference=sheet, identification=self.identification)
|
||||||
elif self.document_type == "TITLEBLOCK":
|
elif self.document_type == "TITLEBLOCK":
|
||||||
titleblock = self.props.titleblock
|
titleblock = props.titleblock
|
||||||
reference = sheet
|
reference = sheet
|
||||||
sheet = tool.Drawing.get_reference_document(reference)
|
sheet = tool.Drawing.get_reference_document(reference)
|
||||||
assert sheet
|
assert sheet
|
||||||
|
|||||||
@@ -419,6 +419,7 @@ class BIM_PT_sheets(Panel):
|
|||||||
draw_project_not_saved_ui(self)
|
draw_project_not_saved_ui(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
assert self.layout
|
||||||
self.props = tool.Drawing.get_document_props()
|
self.props = tool.Drawing.get_document_props()
|
||||||
|
|
||||||
if not self.props.is_editing_sheets:
|
if not self.props.is_editing_sheets:
|
||||||
@@ -432,8 +433,8 @@ class BIM_PT_sheets(Panel):
|
|||||||
row.operator("bim.add_sheet", text="", icon="ADD")
|
row.operator("bim.add_sheet", text="", icon="ADD")
|
||||||
row.operator("bim.disable_editing_sheets", text="", icon="CANCEL")
|
row.operator("bim.disable_editing_sheets", text="", icon="CANCEL")
|
||||||
|
|
||||||
if self.props.sheets and self.props.active_sheet_index < len(self.props.sheets):
|
active_sheet = tool.Drawing.get_active_sheet_item()
|
||||||
active_sheet = self.props.sheets[self.props.active_sheet_index]
|
if active_sheet:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row2 = row.row(align=True)
|
row2 = row.row(align=True)
|
||||||
if active_sheet.is_sheet:
|
if active_sheet.is_sheet:
|
||||||
|
|||||||
@@ -1037,8 +1037,9 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
new.reference_type = reference_description
|
new.reference_type = reference_description
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_active_sheet(cls, context: bpy.types.Context) -> Sheet:
|
def get_active_sheet(cls) -> Sheet:
|
||||||
props = cls.get_document_props()
|
props = cls.get_document_props()
|
||||||
|
# Will also get active sheet even if one of it's subitems selected (drawings, etc).
|
||||||
return next(s for s in props.sheets[: props.active_sheet_index + 1][::-1] if s.is_sheet)
|
return next(s for s in props.sheets[: props.active_sheet_index + 1][::-1] if s.is_sheet)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user