mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Group drawings by target view in the drawing list
This commit is contained in:
@@ -29,6 +29,7 @@ classes = (
|
|||||||
operator.AddDrawingStyle,
|
operator.AddDrawingStyle,
|
||||||
operator.AddDrawingStyleAttribute,
|
operator.AddDrawingStyleAttribute,
|
||||||
operator.AddDrawingToSheet,
|
operator.AddDrawingToSheet,
|
||||||
|
operator.AddReference,
|
||||||
operator.AddReferenceToSheet,
|
operator.AddReferenceToSheet,
|
||||||
operator.AddSchedule,
|
operator.AddSchedule,
|
||||||
operator.AddScheduleToSheet,
|
operator.AddScheduleToSheet,
|
||||||
@@ -37,11 +38,13 @@ classes = (
|
|||||||
operator.BuildSchedule,
|
operator.BuildSchedule,
|
||||||
operator.CleanWireframes,
|
operator.CleanWireframes,
|
||||||
operator.ContractSheet,
|
operator.ContractSheet,
|
||||||
|
operator.ContractTargetView,
|
||||||
operator.CreateDrawing,
|
operator.CreateDrawing,
|
||||||
operator.CreateSheets,
|
operator.CreateSheets,
|
||||||
operator.DisableAddAnnotationType,
|
operator.DisableAddAnnotationType,
|
||||||
operator.DisableEditingAssignedProduct,
|
operator.DisableEditingAssignedProduct,
|
||||||
operator.DisableEditingDrawings,
|
operator.DisableEditingDrawings,
|
||||||
|
operator.DisableEditingReferences,
|
||||||
operator.DisableEditingSchedules,
|
operator.DisableEditingSchedules,
|
||||||
operator.DisableEditingSheets,
|
operator.DisableEditingSheets,
|
||||||
operator.DisableEditingText,
|
operator.DisableEditingText,
|
||||||
@@ -49,36 +52,35 @@ classes = (
|
|||||||
operator.EditAssignedProduct,
|
operator.EditAssignedProduct,
|
||||||
operator.EditSheet,
|
operator.EditSheet,
|
||||||
operator.EditText,
|
operator.EditText,
|
||||||
operator.EnableAddAnnotationType,
|
|
||||||
operator.EditTextPopup,
|
operator.EditTextPopup,
|
||||||
|
operator.EnableAddAnnotationType,
|
||||||
operator.EnableEditingAssignedProduct,
|
operator.EnableEditingAssignedProduct,
|
||||||
operator.EnableEditingText,
|
operator.EnableEditingText,
|
||||||
operator.ExpandSheet,
|
operator.ExpandSheet,
|
||||||
|
operator.ExpandTargetView,
|
||||||
operator.LoadDrawings,
|
operator.LoadDrawings,
|
||||||
|
operator.LoadReferences,
|
||||||
operator.LoadSchedules,
|
operator.LoadSchedules,
|
||||||
operator.LoadSheets,
|
operator.LoadSheets,
|
||||||
operator.OpenDrawing,
|
operator.OpenDrawing,
|
||||||
|
operator.OpenReference,
|
||||||
operator.OpenSchedule,
|
operator.OpenSchedule,
|
||||||
operator.OpenSheet,
|
operator.OpenSheet,
|
||||||
|
operator.ReloadDrawingStyles,
|
||||||
operator.RemoveDrawing,
|
operator.RemoveDrawing,
|
||||||
operator.RemoveDrawingFromSheet,
|
operator.RemoveDrawingFromSheet,
|
||||||
operator.RemoveDrawingStyle,
|
operator.RemoveDrawingStyle,
|
||||||
operator.RemoveDrawingStyleAttribute,
|
operator.RemoveDrawingStyleAttribute,
|
||||||
|
operator.RemoveReference,
|
||||||
operator.RemoveSchedule,
|
operator.RemoveSchedule,
|
||||||
operator.ReloadDrawingStyles,
|
|
||||||
operator.RemoveSheet,
|
operator.RemoveSheet,
|
||||||
operator.RemoveTextLiteral,
|
operator.RemoveTextLiteral,
|
||||||
operator.SelectAllDrawings,
|
|
||||||
operator.ResizeText,
|
operator.ResizeText,
|
||||||
operator.SaveDrawingStyle,
|
operator.SaveDrawingStyle,
|
||||||
operator.SaveDrawingStylesData,
|
operator.SaveDrawingStylesData,
|
||||||
|
operator.SelectAllDrawings,
|
||||||
operator.SelectAssignedProduct,
|
operator.SelectAssignedProduct,
|
||||||
operator.SelectDocIfcFile,
|
operator.SelectDocIfcFile,
|
||||||
operator.LoadReferences,
|
|
||||||
operator.DisableEditingReferences,
|
|
||||||
operator.AddReference,
|
|
||||||
operator.RemoveReference,
|
|
||||||
operator.OpenReference,
|
|
||||||
prop.Variable,
|
prop.Variable,
|
||||||
prop.Drawing,
|
prop.Drawing,
|
||||||
prop.Document,
|
prop.Document,
|
||||||
|
|||||||
@@ -2345,6 +2345,34 @@ class DisableEditingDrawings(bpy.types.Operator, Operator):
|
|||||||
core.disable_editing_drawings(tool.Drawing)
|
core.disable_editing_drawings(tool.Drawing)
|
||||||
|
|
||||||
|
|
||||||
|
class ExpandTargetView(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.expand_target_view"
|
||||||
|
bl_label = "Expand Target View"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
target_view: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.DocProperties
|
||||||
|
for drawing in [d for d in props.drawings if d.target_view == self.target_view]:
|
||||||
|
drawing.is_expanded = True
|
||||||
|
core.load_drawings(tool.Drawing)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class ContractTargetView(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.contract_target_view"
|
||||||
|
bl_label = "Contract Target View"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
target_view: bpy.props.StringProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
props = context.scene.DocProperties
|
||||||
|
for drawing in [d for d in props.drawings if d.target_view == self.target_view]:
|
||||||
|
drawing.is_expanded = False
|
||||||
|
core.load_drawings(tool.Drawing)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class ExpandSheet(bpy.types.Operator):
|
class ExpandSheet(bpy.types.Operator):
|
||||||
bl_idname = "bim.expand_sheet"
|
bl_idname = "bim.expand_sheet"
|
||||||
bl_label = "Expand Sheet"
|
bl_label = "Expand Sheet"
|
||||||
|
|||||||
@@ -165,8 +165,9 @@ def get_diagram_scales(self, context):
|
|||||||
|
|
||||||
|
|
||||||
def update_drawing_name(self, context):
|
def update_drawing_name(self, context):
|
||||||
drawing = tool.Ifc.get().by_id(self.ifc_definition_id)
|
if self.ifc_definition_id:
|
||||||
core.update_drawing_name(tool.Ifc, tool.Drawing, drawing=drawing, name=self.name)
|
drawing = tool.Ifc.get().by_id(self.ifc_definition_id)
|
||||||
|
core.update_drawing_name(tool.Ifc, tool.Drawing, drawing=drawing, name=self.name)
|
||||||
|
|
||||||
|
|
||||||
def get_drawing_style_name(self):
|
def get_drawing_style_name(self):
|
||||||
@@ -253,6 +254,8 @@ class Drawing(PropertyGroup):
|
|||||||
name: StringProperty(name="Name", update=update_drawing_name)
|
name: StringProperty(name="Name", update=update_drawing_name)
|
||||||
target_view: StringProperty(name="Target View")
|
target_view: StringProperty(name="Target View")
|
||||||
is_selected: BoolProperty(name="Is Selected", default=True)
|
is_selected: BoolProperty(name="Is Selected", default=True)
|
||||||
|
is_drawing: BoolProperty(name="Is Drawing", default=False)
|
||||||
|
is_expanded: BoolProperty(name="Is Expanded", default=True)
|
||||||
|
|
||||||
|
|
||||||
class Document(PropertyGroup):
|
class Document(PropertyGroup):
|
||||||
|
|||||||
@@ -488,12 +488,20 @@ class BIM_PT_text(Panel):
|
|||||||
|
|
||||||
class BIM_UL_drawinglist(bpy.types.UIList):
|
class BIM_UL_drawinglist(bpy.types.UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if not item:
|
||||||
row = layout.row(align=True)
|
layout.label(text="", translate=False)
|
||||||
|
return
|
||||||
|
|
||||||
|
row = layout.row(align=True)
|
||||||
|
if item.is_drawing:
|
||||||
|
row.label(text="", icon="BLANK1")
|
||||||
selected_icon = "CHECKBOX_HLT" if item.is_selected else "CHECKBOX_DEHLT"
|
selected_icon = "CHECKBOX_HLT" if item.is_selected else "CHECKBOX_DEHLT"
|
||||||
row.prop(item, "is_selected", text="", icon=selected_icon)
|
row.prop(item, "is_selected", text="", icon=selected_icon, emboss=False)
|
||||||
icon = "UV_FACESEL"
|
row.prop(item, "name", text="", emboss=False)
|
||||||
if item.target_view == "ELEVATION_VIEW":
|
else:
|
||||||
|
if item.target_view == "PLAN_VIEW":
|
||||||
|
icon = "UV_FACESEL"
|
||||||
|
elif item.target_view == "ELEVATION_VIEW":
|
||||||
icon = "UV_VERTEXSEL"
|
icon = "UV_VERTEXSEL"
|
||||||
elif item.target_view == "SECTION_VIEW":
|
elif item.target_view == "SECTION_VIEW":
|
||||||
icon = "UV_EDGESEL"
|
icon = "UV_EDGESEL"
|
||||||
@@ -501,9 +509,18 @@ class BIM_UL_drawinglist(bpy.types.UIList):
|
|||||||
icon = "XRAY"
|
icon = "XRAY"
|
||||||
elif item.target_view == "MODEL_VIEW":
|
elif item.target_view == "MODEL_VIEW":
|
||||||
icon = "SNAP_VOLUME"
|
icon = "SNAP_VOLUME"
|
||||||
|
else:
|
||||||
|
icon = "CLIPUV_HLT"
|
||||||
|
if item.is_expanded:
|
||||||
|
row.operator(
|
||||||
|
"bim.contract_target_view", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||||
|
).target_view = item.target_view
|
||||||
|
else:
|
||||||
|
row.operator(
|
||||||
|
"bim.expand_target_view", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||||
|
).target_view = item.target_view
|
||||||
row.prop(item, "name", text="", icon=icon, emboss=False)
|
row.prop(item, "name", text="", icon=icon, emboss=False)
|
||||||
else:
|
|
||||||
layout.label(text="", translate=False)
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_sheets(bpy.types.UIList):
|
class BIM_UL_sheets(bpy.types.UIList):
|
||||||
|
|||||||
@@ -627,17 +627,38 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_drawings(cls):
|
def import_drawings(cls):
|
||||||
current_drawings_selection = {
|
props = bpy.context.scene.DocProperties
|
||||||
d.ifc_definition_id: d.is_selected for d in bpy.context.scene.DocProperties.drawings
|
expanded_target_views = {d.target_view for d in props.drawings if d.is_expanded}
|
||||||
}
|
current_drawings_selection = {d.ifc_definition_id: d.is_selected for d in props.drawings}
|
||||||
bpy.context.scene.DocProperties.drawings.clear()
|
props.drawings.clear()
|
||||||
drawings = [e for e in tool.Ifc.get().by_type("IfcAnnotation") if e.ObjectType == "DRAWING"]
|
drawings = [e for e in tool.Ifc.get().by_type("IfcAnnotation") if e.ObjectType == "DRAWING"]
|
||||||
|
grouped_drawings = {
|
||||||
|
"MODEL_VIEW": [],
|
||||||
|
"PLAN_VIEW": [],
|
||||||
|
"SECTION_VIEW": [],
|
||||||
|
"ELEVATION_VIEW": [],
|
||||||
|
"REFLECTED_PLAN_VIEW": [],
|
||||||
|
}
|
||||||
for drawing in drawings:
|
for drawing in drawings:
|
||||||
new = bpy.context.scene.DocProperties.drawings.add()
|
target_view = cls.get_drawing_target_view(drawing)
|
||||||
new.ifc_definition_id = drawing.id()
|
grouped_drawings.setdefault(target_view, []).append(drawing)
|
||||||
new.name = drawing.Name or "Unnamed"
|
|
||||||
new.target_view = cls.get_drawing_target_view(drawing)
|
for target_view, drawings in grouped_drawings.items():
|
||||||
new.is_selected = current_drawings_selection.get(drawing.id(), True)
|
new = props.drawings.add()
|
||||||
|
new.name = target_view.replace("_", " ").title() + f" ({len(drawings)})"
|
||||||
|
new.target_view = target_view
|
||||||
|
new.is_drawing = False
|
||||||
|
new.is_expanded = target_view in expanded_target_views
|
||||||
|
|
||||||
|
if not new.is_expanded:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for drawing in sorted(drawings, key=lambda x: x.Name or "Unnamed"):
|
||||||
|
new = props.drawings.add()
|
||||||
|
new.ifc_definition_id = drawing.id()
|
||||||
|
new.name = drawing.Name or "Unnamed"
|
||||||
|
new.is_selected = current_drawings_selection.get(drawing.id(), True)
|
||||||
|
new.is_drawing = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_documents(cls, document_type):
|
def import_documents(cls, document_type):
|
||||||
|
|||||||
Reference in New Issue
Block a user