mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix bug where changing object visibility didn't first check for view layer existence.
This commit is contained in:
@@ -940,7 +940,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
|
||||
context.area.type = old
|
||||
for global_id in exception_global_ids:
|
||||
obj = IfcStore.get_element(global_id)
|
||||
if obj:
|
||||
if obj and bpy.context.view_layer.objects.get(obj.name):
|
||||
obj.hide_set(True)
|
||||
else:
|
||||
objs = []
|
||||
|
||||
@@ -288,8 +288,9 @@ class CreateDrawing(bpy.types.Operator):
|
||||
else:
|
||||
previous_visibility = {}
|
||||
for obj in self.camera.users_collection[0].objects:
|
||||
previous_visibility[obj.name] = obj.hide_get()
|
||||
obj.hide_set(True)
|
||||
if bpy.context.view_layer.objects.get(obj.name):
|
||||
previous_visibility[obj.name] = obj.hide_get()
|
||||
obj.hide_set(True)
|
||||
for obj in context.visible_objects:
|
||||
if (
|
||||
(not obj.data and not obj.instance_collection)
|
||||
@@ -298,8 +299,9 @@ class CreateDrawing(bpy.types.Operator):
|
||||
or "IfcGridAxis/" in obj.name
|
||||
or "IfcOpeningElement/" in obj.name
|
||||
):
|
||||
previous_visibility[obj.name] = obj.hide_get()
|
||||
obj.hide_set(True)
|
||||
if bpy.context.view_layer.objects.get(obj.name):
|
||||
previous_visibility[obj.name] = obj.hide_get()
|
||||
obj.hide_set(True)
|
||||
|
||||
space = self.get_view_3d(context.screen.areas)
|
||||
previous_shading = space.shading.type
|
||||
|
||||
@@ -895,7 +895,8 @@ class QtoCalculator:
|
||||
|
||||
# add object to scene collection and then hide them.
|
||||
collection.objects.get(new_OBB_object.name, collection.objects.link(new_OBB_object))
|
||||
new_OBB_object.hide_set(True)
|
||||
if bpy.context.view_layer.objects.get(new_OBB_object.name):
|
||||
new_OBB_object.hide_set(True)
|
||||
|
||||
return new_OBB_object
|
||||
|
||||
@@ -948,7 +949,8 @@ class QtoCalculator:
|
||||
|
||||
# add object to scene collection and then hide them.
|
||||
collection.objects.link(new_AABB_object)
|
||||
new_AABB_object.hide_set(True)
|
||||
if bpy.context.view_layer.objects.get(new_AABB_object.name):
|
||||
new_AABB_object.hide_set(True)
|
||||
|
||||
return new_AABB_object
|
||||
|
||||
@@ -992,7 +994,8 @@ class QtoCalculator:
|
||||
bpy.ops.mesh.select_all(action="SELECT")
|
||||
bpy.ops.mesh.bisect(plane_co=plane_co_neg, plane_no=plane_no_neg, use_fill=True, clear_outer=True)
|
||||
bpy.ops.object.editmode_toggle()
|
||||
bis_obj.hide_set(True)
|
||||
if bpy.context.view_layer.objects.get(bis_obj.name):
|
||||
bis_obj.hide_set(True)
|
||||
|
||||
return bis_obj
|
||||
|
||||
|
||||
@@ -1424,8 +1424,9 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
bpy.ops.object.hide_view_clear()
|
||||
|
||||
for hidden_obj in hidden_objs:
|
||||
hidden_obj.hide_set(True)
|
||||
hidden_obj.hide_render = True
|
||||
if bpy.context.view_layer.objects.get(hidden_obj.name):
|
||||
hidden_obj.hide_set(True)
|
||||
hidden_obj.hide_render = True
|
||||
|
||||
subcontexts = []
|
||||
target_view = cls.get_drawing_target_view(drawing)
|
||||
|
||||
@@ -139,7 +139,7 @@ class Spatial(blenderbim.core.tool.Spatial):
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
for product in products:
|
||||
obj = tool.Ifc.get_object(product)
|
||||
if obj:
|
||||
if obj and bpy.context.view_layer.objects.get(obj.name):
|
||||
obj.select_set(True)
|
||||
if unhide:
|
||||
obj.hide_set(False)
|
||||
@@ -150,12 +150,12 @@ class Spatial(blenderbim.core.tool.Spatial):
|
||||
if action == "select":
|
||||
[obj.select_set(True) for obj in objects]
|
||||
elif action == "isolate":
|
||||
[obj.hide_set(False) for obj in objects]
|
||||
[obj.hide_set(True) for obj in bpy.context.visible_objects if not obj in objects] # this is slow
|
||||
[obj.hide_set(False) for obj in objects if bpy.context.view_layer.objects.get(obj.name)]
|
||||
[obj.hide_set(True) for obj in bpy.context.visible_objects if not obj in objects and bpy.context.view_layer.objects.get(obj.name)] # this is slow
|
||||
elif action == "unhide":
|
||||
[obj.hide_set(False) for obj in objects]
|
||||
[obj.hide_set(False) for obj in objects if bpy.context.view_layer.objects.get(obj.name)]
|
||||
elif action == "hide":
|
||||
[obj.hide_set(True) for obj in objects]
|
||||
[obj.hide_set(True) for obj in objects if bpy.context.view_layer.objects.get(obj.name)]
|
||||
|
||||
@classmethod
|
||||
def deselect_objects(cls):
|
||||
@@ -164,7 +164,7 @@ class Spatial(blenderbim.core.tool.Spatial):
|
||||
|
||||
@classmethod
|
||||
def show_scene_objects(cls):
|
||||
[obj.hide_set(False) for obj in bpy.data.scenes["Scene"].objects]
|
||||
[obj.hide_set(False) for obj in bpy.data.scenes["Scene"].objects if bpy.context.view_layer.objects.get(obj.name)]
|
||||
|
||||
@classmethod
|
||||
def get_selected_products(cls):
|
||||
|
||||
Reference in New Issue
Block a user