Prepare for pull request

This commit is contained in:
Kristoffer
2020-11-13 14:45:08 +01:00
parent aca90b38c8
commit b9e34a107b
6 changed files with 14 additions and 79 deletions
@@ -18,6 +18,7 @@ import site
cwd = os.path.dirname(os.path.realpath(__file__))
site.addsitedir(os.path.join(cwd, "libs", "site", "packages"))
# main import
from .bim import *
@@ -983,7 +983,6 @@ class IfcParser:
pl = representation["presentation_layer"]
if pl.name == '':
continue
print("Presentation load: ", pl.name)
self.presentation_layer_assignments.setdefault(pl.name, []).append(representation)
def load_representations(self):
@@ -3248,10 +3247,7 @@ class IfcExporter:
return results
def relate_spaces_to_boundary_elements(self):
for (
relating_space_index,
relationships,
) in self.ifc_parser.rel_space_boundaries.items():
for (relating_space_index, relationships,) in self.ifc_parser.rel_space_boundaries.items():
for relationship in relationships:
relationship["attributes"]["GlobalId"] = ifcopenshell.guid.new()
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_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:
guid = item.OfProductRepresentation[0].ShapeOfProduct[0].GlobalId
for obj in bpy.context.selectable_objects:
global_id = obj.BIMObjectProperties.attributes.get("GlobalId")
if global_id and global_id.string_value == guid:
obj.BIMObjectProperties.presentation_layer.name = pl.name
# vl.objects.data.layer_collection.collection.objects.link(obj)
coll.objects.link(obj)
obj.hide_set(not pl.layer_on)
def clean_mesh(self):
obj = None
+10 -30
View File
@@ -4324,15 +4324,12 @@ class AddToPresentationLayer(bpy.types.Operator):
def execute(self, context):
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)
# vl = bpy.context.scene.view_layers[presentation_layer.name]
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})"')
return {"FINISHED"}
@@ -4374,9 +4371,6 @@ class RemovePresentationLayer(bpy.types.Operator):
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"}
@@ -4384,29 +4378,15 @@ class RemovePresentationLayer(bpy.types.Operator):
class UpdatePresentationLayer(bpy.types.Operator):
bl_idname = "bim.update_presentation_layer"
bl_label = "Update Presentation Layer"
bl_label = "Hide/Show selected Presentation Layer"
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):
pl = bpy.context.scene.BIMProperties.presentation_layers[self.index]
pl.name = self.pl_name
pl.description = self.pl_description
pl.identifier = self.pl_identifier
pl.layer_on = self.pl_layer_on
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
for obj in bpy.context.scene.objects:
if obj.BIMObjectProperties.presentation_layer.name == pl.name:
set_status = obj.hide_get()
obj.hide_set(not obj.hide_get())
return {"FINISHED"}
@@ -259,26 +259,6 @@ def refreshBoundaryConditionAttributes(self, context):
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):
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")
has_boundary_condition: BoolProperty(name="Has Boundary Condition")
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)
structural_member_connection: PointerProperty(name="Structural Member Connection", type=bpy.types.Object)
representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext)
+1 -6
View File
@@ -1003,12 +1003,7 @@ class BIM_PT_presentation_layers(Panel):
op = layout.row().operator("bim.update_presentation_layer")
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")