mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Finished with creating, exporting Presentation Layer. Will start work on importing Presentation layer
This commit is contained in:
@@ -205,6 +205,7 @@ if bpy is not None:
|
||||
operator.GetNorthOffset,
|
||||
operator.AddPresentationLayer,
|
||||
operator.AddToPresentationLayer,
|
||||
operator.RemoveFromPresentationLayer,
|
||||
operator.RemovePresentationLayer,
|
||||
operator.UpdatePresentationLayer,
|
||||
operator.AddDrawingStyleAttribute,
|
||||
|
||||
@@ -4286,11 +4286,30 @@ class AddToPresentationLayer(bpy.types.Operator):
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
name = bpy.context.scene.BIMProperties.presentation_layers[self.index].name
|
||||
bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name
|
||||
bpy.context.active_object.BIMObjectProperties.presentation_layer.name = name
|
||||
elem_name = bpy.context.active_object.BIMObjectProperties.attributes["Name"].string_value
|
||||
print(f'Adding "({self.index} - {name})" to "{elem_name}"')
|
||||
presentation_layer = bpy.context.scene.BIMProperties.presentation_layers[self.index]
|
||||
|
||||
vl = bpy.context.scene.view_layers[presentation_layer.name]
|
||||
|
||||
for el in bpy.context.selected_objects:
|
||||
el.BIMObjectProperties.presentation_layer.name = presentation_layer.name
|
||||
elem_name = el.BIMObjectProperties.attributes["Name"].string_value
|
||||
|
||||
# TODO: I want to add the selected elements to a view layer. But how do you append objects to a view_layer?
|
||||
# vl.objects.append(el)
|
||||
|
||||
print(f'Adding "{elem_name}" to View/Presentation Layer "({self.index} - {presentation_layer.name})"')
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveFromPresentationLayer(bpy.types.Operator):
|
||||
bl_idname = "bim.remove_from_presentation_layer"
|
||||
bl_label = "Remove Selected From Presentation Layer"
|
||||
|
||||
def execute(self, context):
|
||||
for el in bpy.context.selected_objects:
|
||||
if el.BIMObjectProperties.presentation_layer.name != '':
|
||||
el.BIMObjectProperties.presentation_layer.name = ''
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -4318,9 +4337,12 @@ class RemovePresentationLayer(bpy.types.Operator):
|
||||
bl_label = "Remove Presentation Layer"
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
|
||||
def execute(self, context):
|
||||
pl = bpy.context.scene.BIMProperties.presentation_layers[self.index]
|
||||
if pl.name not in bpy.context.scene.view_layers.keys():
|
||||
bpy.context.scene.view_layers.remove(pl.name)
|
||||
bpy.context.scene.BIMProperties.presentation_layers.remove(self.index)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -4344,6 +4366,11 @@ class UpdatePresentationLayer(bpy.types.Operator):
|
||||
pl.layer_frozen = self.pl_layer_frozen
|
||||
pl.layer_blocked = self.pl_layer_blocked
|
||||
|
||||
if pl.name not in bpy.context.scene.view_layers.keys():
|
||||
new = bpy.context.scene.view_layers.new(pl.name)
|
||||
# if pl.layer_on is False:
|
||||
# bpy.context.scene.view_layers
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -259,11 +259,11 @@ class BIM_PT_object_qto(Panel):
|
||||
row.prop(prop, "name", text="")
|
||||
row.prop(prop, "string_value", text="")
|
||||
if (
|
||||
"length" in prop.name.lower()
|
||||
or "width" in prop.name.lower()
|
||||
or "height" in prop.name.lower()
|
||||
or "depth" in prop.name.lower()
|
||||
or "perimeter" in prop.name.lower()
|
||||
"length" in prop.name.lower()
|
||||
or "width" in prop.name.lower()
|
||||
or "height" in prop.name.lower()
|
||||
or "depth" in prop.name.lower()
|
||||
or "perimeter" in prop.name.lower()
|
||||
):
|
||||
op = row.operator("bim.guess_quantity", icon="IPO_EASE_IN_OUT", text="")
|
||||
op.qto_index = index
|
||||
@@ -710,9 +710,9 @@ class BIM_PT_mesh(Panel):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (
|
||||
context.active_object is not None
|
||||
and context.active_object.type == "MESH"
|
||||
and hasattr(context.active_object.data, "BIMMeshProperties")
|
||||
context.active_object is not None
|
||||
and context.active_object.type == "MESH"
|
||||
and hasattr(context.active_object.data, "BIMMeshProperties")
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
@@ -776,26 +776,21 @@ class BIM_PT_presentation_layer_data(Panel):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (
|
||||
context.active_object is not None
|
||||
and context.active_object.type == "MESH"
|
||||
and hasattr(context.active_object.data, "BIMMeshProperties")
|
||||
context.active_object is not None
|
||||
and context.active_object.type == "MESH"
|
||||
and hasattr(context.active_object.data, "BIMMeshProperties")
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
if not context.active_object.data:
|
||||
return
|
||||
layout = self.layout
|
||||
elem_props = context.active_object.data.BIMMeshProperties.presentation_layer
|
||||
elem_props = context.active_object.BIMObjectProperties.presentation_layer
|
||||
scene_props = context.scene.BIMProperties
|
||||
|
||||
if elem_props.name != "":
|
||||
layout.row(align=True).prop(elem_props, "name")
|
||||
layout.row().prop(elem_props, "description")
|
||||
layout.row().prop(elem_props, "identifier")
|
||||
layout.row().prop(elem_props, "layer_on")
|
||||
layout.row().prop(elem_props, "layer_frozen")
|
||||
layout.row().prop(elem_props, "layer_blocked")
|
||||
layout.row().prop(elem_props, "layer_styles")
|
||||
layout.label(text=f'Object is part of Presentation layer "{elem_props.name}"')
|
||||
layout.row().operator("bim.remove_from_presentation_layer")
|
||||
else:
|
||||
layout.label(text="Not included in any presentation layer")
|
||||
|
||||
@@ -985,6 +980,11 @@ class BIM_PT_presentation_layers(Panel):
|
||||
op.index = props.active_presentation_layer_index
|
||||
op.pl_name = pres_layer.name
|
||||
op.pl_description = pres_layer.description
|
||||
op.pl_identifier = pres_layer.identifier
|
||||
op.pl_layer_on = pres_layer.layer_on
|
||||
op.pl_layer_frozen = pres_layer.layer_frozen
|
||||
op.pl_layer_blocked = pres_layer.layer_blocked
|
||||
|
||||
else:
|
||||
layout.label(text="Presentation Layer is invalid")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user