mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Support adding IfcPresentationLayerWithStyle from UI
Example - https://i.imgur.com/0mssU2s.png
This commit is contained in:
@@ -81,12 +81,18 @@ class DisableEditingLayer(bpy.types.Operator):
|
||||
class AddPresentationLayer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.add_presentation_layer"
|
||||
bl_label = "Add Layer"
|
||||
bl_description = "Add new presentation layer."
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
result = ifcopenshell.api.run("layer.add_layer", IfcStore.get_file())
|
||||
props = context.scene.BIMLayerProperties
|
||||
ifc_file = tool.Ifc.get()
|
||||
if props.layer_type == "IfcPresentationLayerWithStyle":
|
||||
layer = ifcopenshell.api.layer.add_layer_with_style(ifc_file)
|
||||
else:
|
||||
layer = ifcopenshell.api.layer.add_layer(ifc_file)
|
||||
bpy.ops.bim.load_layers()
|
||||
bpy.ops.bim.enable_editing_layer(layer=result.id())
|
||||
bpy.ops.bim.enable_editing_layer(layer=layer.id())
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -42,3 +42,12 @@ class BIMLayerProperties(PropertyGroup):
|
||||
layers: CollectionProperty(name="Layers", type=Layer)
|
||||
active_layer_index: IntProperty(name="Active Layer Index")
|
||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
||||
layer_type: EnumProperty(
|
||||
name="Presentation Layer Type",
|
||||
description="Presentation layer type to add",
|
||||
items=(
|
||||
("IfcPresentationLayerAssignment", "IfcPresentationLayerAssignment", ""),
|
||||
("IfcPresentationLayerWithStyle", "IfcPresentationLayerWithStyle", ""),
|
||||
),
|
||||
default="IfcPresentationLayerAssignment",
|
||||
)
|
||||
|
||||
@@ -43,12 +43,15 @@ class BIM_PT_layers(Panel):
|
||||
self.props = context.scene.BIMLayerProperties
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=f"{LayersData.data['total_layers']} Layers Found")
|
||||
if self.props.is_editing:
|
||||
row.operator("bim.add_presentation_layer", text="", icon="ADD")
|
||||
row.operator("bim.disable_layer_editing_ui", text="", icon="CANCEL")
|
||||
else:
|
||||
row.label(text=f"{LayersData.data['total_layers']} Layers Found", icon="STICKY_UVS_LOC")
|
||||
if not self.props.is_editing:
|
||||
row.operator("bim.load_layers", text="", icon="GREASEPENCIL")
|
||||
return
|
||||
|
||||
row.operator("bim.disable_layer_editing_ui", text="", icon="CANCEL")
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(self.props, "layer_type", text="")
|
||||
row.operator("bim.add_presentation_layer", text="", icon="ADD")
|
||||
|
||||
if self.props.is_editing:
|
||||
self.layout.template_list(
|
||||
|
||||
Reference in New Issue
Block a user