mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +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):
|
class AddPresentationLayer(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.add_presentation_layer"
|
bl_idname = "bim.add_presentation_layer"
|
||||||
bl_label = "Add Layer"
|
bl_label = "Add Layer"
|
||||||
|
bl_description = "Add new presentation layer."
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
def _execute(self, context):
|
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.load_layers()
|
||||||
bpy.ops.bim.enable_editing_layer(layer=result.id())
|
bpy.ops.bim.enable_editing_layer(layer=layer.id())
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,3 +42,12 @@ class BIMLayerProperties(PropertyGroup):
|
|||||||
layers: CollectionProperty(name="Layers", type=Layer)
|
layers: CollectionProperty(name="Layers", type=Layer)
|
||||||
active_layer_index: IntProperty(name="Active Layer Index")
|
active_layer_index: IntProperty(name="Active Layer Index")
|
||||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
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
|
self.props = context.scene.BIMLayerProperties
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=f"{LayersData.data['total_layers']} Layers Found")
|
row.label(text=f"{LayersData.data['total_layers']} Layers Found", icon="STICKY_UVS_LOC")
|
||||||
if self.props.is_editing:
|
if not 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.operator("bim.load_layers", text="", icon="GREASEPENCIL")
|
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:
|
if self.props.is_editing:
|
||||||
self.layout.template_list(
|
self.layout.template_list(
|
||||||
|
|||||||
Reference in New Issue
Block a user