mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 02:24:30 +00:00
Quick way to select style in Styles UI
Example - https://imgchest.com/p/ej7mkxp9ayd
This commit is contained in:
@@ -2153,6 +2153,7 @@ class EnableEditingRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
|
||||
for style in styles:
|
||||
if style.is_a("IfcSurfaceStyle"):
|
||||
new.surface_style = style.Name or "Unnamed"
|
||||
new.surface_style_id = style.id()
|
||||
elif inverse.is_a("IfcPresentationLayerAssignment"):
|
||||
new.layer = inverse.Name or "Unnamed"
|
||||
elif inverse.is_a("IfcShapeRepresentation"):
|
||||
|
||||
@@ -119,6 +119,7 @@ def update_shape_aspect(self, context):
|
||||
class RepresentationItem(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
surface_style: StringProperty(name="Surface Style")
|
||||
surface_style_id: IntProperty(name="Surface Style ID")
|
||||
layer: StringProperty(name="Layer")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
shape_aspect: StringProperty(name="Shape Aspect")
|
||||
|
||||
@@ -211,6 +211,7 @@ class BIM_PT_representation_items(Panel):
|
||||
|
||||
active_item = props.items[props.active_item_index]
|
||||
surface_style = active_item.surface_style
|
||||
surface_style_id = active_item.surface_style_id
|
||||
shape_aspect = active_item.shape_aspect
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
@@ -223,6 +224,8 @@ class BIM_PT_representation_items(Panel):
|
||||
else:
|
||||
if surface_style:
|
||||
row.label(text=surface_style, icon="SHADING_RENDERED")
|
||||
op = row.operator("bim.styles_ui_select", icon="ZOOM_SELECTED", text="")
|
||||
op.style_id = surface_style_id
|
||||
else:
|
||||
row.label(text="No Surface Style", icon="MESH_UVSPHERE")
|
||||
row.operator("bim.enable_editing_representation_item_style", icon="GREASEPENCIL", text="")
|
||||
|
||||
@@ -96,6 +96,8 @@ class BIM_PT_materials(Panel):
|
||||
row.label(text=style["context_identifier"])
|
||||
row.label(text=style["target_view"])
|
||||
row.label(text=style["name"])
|
||||
op = row.operator("bim.styles_ui_select", icon="ZOOM_SELECTED", text="")
|
||||
op.style_id = style["id"]
|
||||
op = row.operator("bim.unassign_material_style", text="", icon="X")
|
||||
op.style = style["id"]
|
||||
op.context = style["context_id"]
|
||||
|
||||
@@ -41,6 +41,7 @@ classes = (
|
||||
operator.RemoveStyle,
|
||||
operator.SaveUVToStyle,
|
||||
operator.SelectByStyle,
|
||||
operator.SelectStyleInStylesUI,
|
||||
operator.UnlinkStyle,
|
||||
operator.UpdateCurrentStyle,
|
||||
operator.UpdateStyleColours,
|
||||
|
||||
@@ -1119,3 +1119,23 @@ class AssignStyleToSelected(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
tool.Geometry.reload_representation(representations.values())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectStyleInStylesUI(bpy.types.Operator):
|
||||
bl_idname = "bim.styles_ui_select"
|
||||
bl_label = "Select Style In Styles UI"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
style_id: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = bpy.context.scene.BIMStylesProperties
|
||||
ifc_file = tool.Ifc.get()
|
||||
style = ifc_file.by_id(self.style_id)
|
||||
core.load_styles(tool.Style, style.is_a())
|
||||
|
||||
props.active_style_index = next((i for i, m in enumerate(props.styles) if m.ifc_definition_id == self.style_id))
|
||||
self.report(
|
||||
{"INFO"},
|
||||
f"Style '{style.Name or 'Unnamed'}' is selected in Styles UI.",
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
Reference in New Issue
Block a user