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