mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Group drawings by target view in the drawing list
This commit is contained in:
@@ -29,6 +29,7 @@ classes = (
|
||||
operator.AddDrawingStyle,
|
||||
operator.AddDrawingStyleAttribute,
|
||||
operator.AddDrawingToSheet,
|
||||
operator.AddReference,
|
||||
operator.AddReferenceToSheet,
|
||||
operator.AddSchedule,
|
||||
operator.AddScheduleToSheet,
|
||||
@@ -37,11 +38,13 @@ classes = (
|
||||
operator.BuildSchedule,
|
||||
operator.CleanWireframes,
|
||||
operator.ContractSheet,
|
||||
operator.ContractTargetView,
|
||||
operator.CreateDrawing,
|
||||
operator.CreateSheets,
|
||||
operator.DisableAddAnnotationType,
|
||||
operator.DisableEditingAssignedProduct,
|
||||
operator.DisableEditingDrawings,
|
||||
operator.DisableEditingReferences,
|
||||
operator.DisableEditingSchedules,
|
||||
operator.DisableEditingSheets,
|
||||
operator.DisableEditingText,
|
||||
@@ -49,36 +52,35 @@ classes = (
|
||||
operator.EditAssignedProduct,
|
||||
operator.EditSheet,
|
||||
operator.EditText,
|
||||
operator.EnableAddAnnotationType,
|
||||
operator.EditTextPopup,
|
||||
operator.EnableAddAnnotationType,
|
||||
operator.EnableEditingAssignedProduct,
|
||||
operator.EnableEditingText,
|
||||
operator.ExpandSheet,
|
||||
operator.ExpandTargetView,
|
||||
operator.LoadDrawings,
|
||||
operator.LoadReferences,
|
||||
operator.LoadSchedules,
|
||||
operator.LoadSheets,
|
||||
operator.OpenDrawing,
|
||||
operator.OpenReference,
|
||||
operator.OpenSchedule,
|
||||
operator.OpenSheet,
|
||||
operator.ReloadDrawingStyles,
|
||||
operator.RemoveDrawing,
|
||||
operator.RemoveDrawingFromSheet,
|
||||
operator.RemoveDrawingStyle,
|
||||
operator.RemoveDrawingStyleAttribute,
|
||||
operator.RemoveReference,
|
||||
operator.RemoveSchedule,
|
||||
operator.ReloadDrawingStyles,
|
||||
operator.RemoveSheet,
|
||||
operator.RemoveTextLiteral,
|
||||
operator.SelectAllDrawings,
|
||||
operator.ResizeText,
|
||||
operator.SaveDrawingStyle,
|
||||
operator.SaveDrawingStylesData,
|
||||
operator.SelectAllDrawings,
|
||||
operator.SelectAssignedProduct,
|
||||
operator.SelectDocIfcFile,
|
||||
operator.LoadReferences,
|
||||
operator.DisableEditingReferences,
|
||||
operator.AddReference,
|
||||
operator.RemoveReference,
|
||||
operator.OpenReference,
|
||||
prop.Variable,
|
||||
prop.Drawing,
|
||||
prop.Document,
|
||||
|
||||
@@ -2345,6 +2345,34 @@ class DisableEditingDrawings(bpy.types.Operator, Operator):
|
||||
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):
|
||||
bl_idname = "bim.expand_sheet"
|
||||
bl_label = "Expand Sheet"
|
||||
|
||||
@@ -165,8 +165,9 @@ def get_diagram_scales(self, context):
|
||||
|
||||
|
||||
def update_drawing_name(self, context):
|
||||
drawing = tool.Ifc.get().by_id(self.ifc_definition_id)
|
||||
core.update_drawing_name(tool.Ifc, tool.Drawing, drawing=drawing, name=self.name)
|
||||
if self.ifc_definition_id:
|
||||
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):
|
||||
@@ -253,6 +254,8 @@ class Drawing(PropertyGroup):
|
||||
name: StringProperty(name="Name", update=update_drawing_name)
|
||||
target_view: StringProperty(name="Target View")
|
||||
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):
|
||||
|
||||
@@ -488,12 +488,20 @@ class BIM_PT_text(Panel):
|
||||
|
||||
class BIM_UL_drawinglist(bpy.types.UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
if not item:
|
||||
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"
|
||||
row.prop(item, "is_selected", text="", icon=selected_icon)
|
||||
icon = "UV_FACESEL"
|
||||
if item.target_view == "ELEVATION_VIEW":
|
||||
row.prop(item, "is_selected", text="", icon=selected_icon, emboss=False)
|
||||
row.prop(item, "name", text="", emboss=False)
|
||||
else:
|
||||
if item.target_view == "PLAN_VIEW":
|
||||
icon = "UV_FACESEL"
|
||||
elif item.target_view == "ELEVATION_VIEW":
|
||||
icon = "UV_VERTEXSEL"
|
||||
elif item.target_view == "SECTION_VIEW":
|
||||
icon = "UV_EDGESEL"
|
||||
@@ -501,9 +509,18 @@ class BIM_UL_drawinglist(bpy.types.UIList):
|
||||
icon = "XRAY"
|
||||
elif item.target_view == "MODEL_VIEW":
|
||||
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)
|
||||
else:
|
||||
layout.label(text="", translate=False)
|
||||
|
||||
|
||||
|
||||
class BIM_UL_sheets(bpy.types.UIList):
|
||||
|
||||
@@ -627,17 +627,38 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
|
||||
@classmethod
|
||||
def import_drawings(cls):
|
||||
current_drawings_selection = {
|
||||
d.ifc_definition_id: d.is_selected for d in bpy.context.scene.DocProperties.drawings
|
||||
}
|
||||
bpy.context.scene.DocProperties.drawings.clear()
|
||||
props = bpy.context.scene.DocProperties
|
||||
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}
|
||||
props.drawings.clear()
|
||||
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:
|
||||
new = bpy.context.scene.DocProperties.drawings.add()
|
||||
new.ifc_definition_id = drawing.id()
|
||||
new.name = drawing.Name or "Unnamed"
|
||||
new.target_view = cls.get_drawing_target_view(drawing)
|
||||
new.is_selected = current_drawings_selection.get(drawing.id(), True)
|
||||
target_view = cls.get_drawing_target_view(drawing)
|
||||
grouped_drawings.setdefault(target_view, []).append(drawing)
|
||||
|
||||
for target_view, drawings in grouped_drawings.items():
|
||||
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
|
||||
def import_documents(cls, document_type):
|
||||
|
||||
Reference in New Issue
Block a user