mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Prepare for pull request
This commit is contained in:
@@ -18,6 +18,7 @@ import site
|
|||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
site.addsitedir(os.path.join(cwd, "libs", "site", "packages"))
|
site.addsitedir(os.path.join(cwd, "libs", "site", "packages"))
|
||||||
|
|
||||||
|
|
||||||
# main import
|
# main import
|
||||||
from .bim import *
|
from .bim import *
|
||||||
|
|
||||||
|
|||||||
@@ -983,7 +983,6 @@ class IfcParser:
|
|||||||
pl = representation["presentation_layer"]
|
pl = representation["presentation_layer"]
|
||||||
if pl.name == '':
|
if pl.name == '':
|
||||||
continue
|
continue
|
||||||
print("Presentation load: ", pl.name)
|
|
||||||
self.presentation_layer_assignments.setdefault(pl.name, []).append(representation)
|
self.presentation_layer_assignments.setdefault(pl.name, []).append(representation)
|
||||||
|
|
||||||
def load_representations(self):
|
def load_representations(self):
|
||||||
@@ -3248,10 +3247,7 @@ class IfcExporter:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def relate_spaces_to_boundary_elements(self):
|
def relate_spaces_to_boundary_elements(self):
|
||||||
for (
|
for (relating_space_index, relationships,) in self.ifc_parser.rel_space_boundaries.items():
|
||||||
relating_space_index,
|
|
||||||
relationships,
|
|
||||||
) in self.ifc_parser.rel_space_boundaries.items():
|
|
||||||
for relationship in relationships:
|
for relationship in relationships:
|
||||||
relationship["attributes"]["GlobalId"] = ifcopenshell.guid.new()
|
relationship["attributes"]["GlobalId"] = ifcopenshell.guid.new()
|
||||||
relationship["attributes"]["RelatedBuildingElement"] = self.ifc_parser.products[
|
relationship["attributes"]["RelatedBuildingElement"] = self.ifc_parser.products[
|
||||||
|
|||||||
@@ -1321,29 +1321,13 @@ class IfcImporter:
|
|||||||
pl.layer_frozen = f.LayerFrozen if f.LayerFrozen is not None else False
|
pl.layer_frozen = f.LayerFrozen if f.LayerFrozen is not None else False
|
||||||
pl.layer_blocked = f.LayerBlocked if f.LayerBlocked is not None else False
|
pl.layer_blocked = f.LayerBlocked if f.LayerBlocked is not None else False
|
||||||
|
|
||||||
if pl.name not in bpy.context.scene.view_layers.keys():
|
|
||||||
vl = bpy.context.scene.view_layers.new(pl.name)
|
|
||||||
else:
|
|
||||||
vl = bpy.context.scene.view_layers[pl.name]
|
|
||||||
|
|
||||||
if pl.name not in bpy.data.collections.keys():
|
|
||||||
coll = bpy.data.collections.new(pl.name)
|
|
||||||
else:
|
|
||||||
coll = bpy.data.collections[pl.name]
|
|
||||||
|
|
||||||
if pl.layer_on is False:
|
|
||||||
# vl.objects.data.layer_collection.collection.hide_viewport = True
|
|
||||||
# bpy.context.window.view_layer.layer_collection.children[pl.name].exclude = True
|
|
||||||
coll.hide_viewport = True
|
|
||||||
|
|
||||||
for item in f.AssignedItems:
|
for item in f.AssignedItems:
|
||||||
guid = item.OfProductRepresentation[0].ShapeOfProduct[0].GlobalId
|
guid = item.OfProductRepresentation[0].ShapeOfProduct[0].GlobalId
|
||||||
for obj in bpy.context.selectable_objects:
|
for obj in bpy.context.selectable_objects:
|
||||||
global_id = obj.BIMObjectProperties.attributes.get("GlobalId")
|
global_id = obj.BIMObjectProperties.attributes.get("GlobalId")
|
||||||
if global_id and global_id.string_value == guid:
|
if global_id and global_id.string_value == guid:
|
||||||
obj.BIMObjectProperties.presentation_layer.name = pl.name
|
obj.BIMObjectProperties.presentation_layer.name = pl.name
|
||||||
# vl.objects.data.layer_collection.collection.objects.link(obj)
|
obj.hide_set(not pl.layer_on)
|
||||||
coll.objects.link(obj)
|
|
||||||
|
|
||||||
def clean_mesh(self):
|
def clean_mesh(self):
|
||||||
obj = None
|
obj = None
|
||||||
|
|||||||
@@ -4324,15 +4324,12 @@ class AddToPresentationLayer(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
presentation_layer = bpy.context.scene.BIMProperties.presentation_layers[self.index]
|
presentation_layer = bpy.context.scene.BIMProperties.presentation_layers[self.index]
|
||||||
|
|
||||||
vl = bpy.context.scene.view_layers[presentation_layer.name]
|
# 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)
|
|
||||||
|
|
||||||
|
for obj in bpy.context.selected_objects:
|
||||||
|
obj.BIMObjectProperties.presentation_layer.name = presentation_layer.name
|
||||||
|
elem_name = obj.BIMObjectProperties.attributes["Name"].string_value
|
||||||
|
obj.hide_set(not presentation_layer.layer_on)
|
||||||
print(f'Adding "{elem_name}" to View/Presentation Layer "({self.index} - {presentation_layer.name})"')
|
print(f'Adding "{elem_name}" to View/Presentation Layer "({self.index} - {presentation_layer.name})"')
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -4374,9 +4371,6 @@ class RemovePresentationLayer(bpy.types.Operator):
|
|||||||
index: bpy.props.IntProperty()
|
index: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
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)
|
bpy.context.scene.BIMProperties.presentation_layers.remove(self.index)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -4384,29 +4378,15 @@ class RemovePresentationLayer(bpy.types.Operator):
|
|||||||
|
|
||||||
class UpdatePresentationLayer(bpy.types.Operator):
|
class UpdatePresentationLayer(bpy.types.Operator):
|
||||||
bl_idname = "bim.update_presentation_layer"
|
bl_idname = "bim.update_presentation_layer"
|
||||||
bl_label = "Update Presentation Layer"
|
bl_label = "Hide/Show selected Presentation Layer"
|
||||||
index: bpy.props.IntProperty()
|
index: bpy.props.IntProperty()
|
||||||
pl_name = bpy.props.StringProperty()
|
|
||||||
pl_description = bpy.props.StringProperty()
|
|
||||||
pl_identifier = bpy.props.StringProperty()
|
|
||||||
pl_layer_on = bpy.props.BoolProperty()
|
|
||||||
pl_layer_frozen = bpy.props.BoolProperty()
|
|
||||||
pl_layer_blocked = bpy.props.BoolProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
pl = bpy.context.scene.BIMProperties.presentation_layers[self.index]
|
pl = bpy.context.scene.BIMProperties.presentation_layers[self.index]
|
||||||
pl.name = self.pl_name
|
for obj in bpy.context.scene.objects:
|
||||||
pl.description = self.pl_description
|
if obj.BIMObjectProperties.presentation_layer.name == pl.name:
|
||||||
pl.identifier = self.pl_identifier
|
set_status = obj.hide_get()
|
||||||
pl.layer_on = self.pl_layer_on
|
obj.hide_set(not obj.hide_get())
|
||||||
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"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -259,26 +259,6 @@ def refreshBoundaryConditionAttributes(self, context):
|
|||||||
new_attribute.name = attribute["name"]
|
new_attribute.name = attribute["name"]
|
||||||
|
|
||||||
|
|
||||||
def getPresentationLayerClasses(self, context):
|
|
||||||
return [
|
|
||||||
(c, c, "")
|
|
||||||
for c in [
|
|
||||||
"IfcPresentationLayerAssignment",
|
|
||||||
"IfcPresentationLayerWithStyle",
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def refreshPresentationLayerAttributes(self, context):
|
|
||||||
while len(context.active_object.BIMObjectProperties.presentation_layer.attributes) > 0:
|
|
||||||
context.active_object.BIMObjectProperties.presentation_layer.attributes.remove(0)
|
|
||||||
for attribute in schema.ifc.elements[context.active_object.BIMObjectProperties.presentation_layer.name][
|
|
||||||
"complex_attributes"
|
|
||||||
]:
|
|
||||||
new_attribute = context.active_object.BIMObjectProperties.presentation_layer.attributes.add()
|
|
||||||
new_attribute.name = attribute["name"]
|
|
||||||
|
|
||||||
|
|
||||||
def refreshActiveDrawingIndex(self, context):
|
def refreshActiveDrawingIndex(self, context):
|
||||||
bpy.ops.bim.activate_view(drawing_index=context.scene.DocProperties.active_drawing_index)
|
bpy.ops.bim.activate_view(drawing_index=context.scene.DocProperties.active_drawing_index)
|
||||||
|
|
||||||
@@ -1705,7 +1685,6 @@ class BIMObjectProperties(PropertyGroup):
|
|||||||
qto_name: EnumProperty(items=getQtoNames, name="Qto Name")
|
qto_name: EnumProperty(items=getQtoNames, name="Qto Name")
|
||||||
has_boundary_condition: BoolProperty(name="Has Boundary Condition")
|
has_boundary_condition: BoolProperty(name="Has Boundary Condition")
|
||||||
boundary_condition: PointerProperty(name="Boundary Condition", type=BoundaryCondition)
|
boundary_condition: PointerProperty(name="Boundary Condition", type=BoundaryCondition)
|
||||||
active_presentation_layer_index: IntProperty(name="Active Presentation Layer Index")
|
|
||||||
presentation_layer: PointerProperty(name="Presentation Layer", type=PresentationLayer)
|
presentation_layer: PointerProperty(name="Presentation Layer", type=PresentationLayer)
|
||||||
structural_member_connection: PointerProperty(name="Structural Member Connection", type=bpy.types.Object)
|
structural_member_connection: PointerProperty(name="Structural Member Connection", type=bpy.types.Object)
|
||||||
representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext)
|
representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext)
|
||||||
|
|||||||
@@ -1003,12 +1003,7 @@ class BIM_PT_presentation_layers(Panel):
|
|||||||
|
|
||||||
op = layout.row().operator("bim.update_presentation_layer")
|
op = layout.row().operator("bim.update_presentation_layer")
|
||||||
op.index = props.active_presentation_layer_index
|
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:
|
else:
|
||||||
layout.label(text="Presentation Layer is invalid")
|
layout.label(text="Presentation Layer is invalid")
|
||||||
|
|||||||
Reference in New Issue
Block a user