mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
simplify getting view 3d space
If area is VIEW_3D then area.spaces.active is always VIEW_3D too.
This commit is contained in:
@@ -1396,10 +1396,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
for area in areas:
|
for area in areas:
|
||||||
if area.type != "VIEW_3D":
|
if area.type != "VIEW_3D":
|
||||||
continue
|
continue
|
||||||
for space in area.spaces:
|
return area.spaces.active
|
||||||
if space.type != "VIEW_3D":
|
|
||||||
continue
|
|
||||||
return space
|
|
||||||
|
|
||||||
def get_material_name(self, element: ifcopenshell.entity_instance) -> str:
|
def get_material_name(self, element: ifcopenshell.entity_instance) -> str:
|
||||||
if hasattr(element, "Name") and element.Name:
|
if hasattr(element, "Name") and element.Name:
|
||||||
@@ -2298,10 +2295,7 @@ class SaveDrawingStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
for area in context.screen.areas:
|
for area in context.screen.areas:
|
||||||
if area.type != "VIEW_3D":
|
if area.type != "VIEW_3D":
|
||||||
continue
|
continue
|
||||||
for space in area.spaces:
|
return area.spaces.active
|
||||||
if space.type != "VIEW_3D":
|
|
||||||
continue
|
|
||||||
return space
|
|
||||||
|
|
||||||
|
|
||||||
class SaveDrawingStylesData(bpy.types.Operator, tool.Ifc.Operator):
|
class SaveDrawingStylesData(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
@@ -2436,14 +2430,11 @@ class ActivateDrawingStyle(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if global_id in self.exclude_global_ids:
|
if global_id in self.exclude_global_ids:
|
||||||
obj.hide_viewport = True # Note: this breaks alt-H
|
obj.hide_viewport = True # Note: this breaks alt-H
|
||||||
|
|
||||||
def get_view_3d(self, context: bpy.types.Context) -> bpy.types.Space:
|
def get_view_3d(self, context: bpy.types.Context) -> bpy.types.SpaceView3D:
|
||||||
for area in context.screen.areas:
|
for area in context.screen.areas:
|
||||||
if area.type != "VIEW_3D":
|
if area.type != "VIEW_3D":
|
||||||
continue
|
continue
|
||||||
for space in area.spaces:
|
return area.spaces.active
|
||||||
if space.type != "VIEW_3D":
|
|
||||||
continue
|
|
||||||
return space
|
|
||||||
assert False, "Space is not found."
|
assert False, "Space is not found."
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -260,11 +260,9 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
return area
|
return area
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_view3d_space(cls):
|
def get_view3d_space(cls) -> Union[bpy.types.SpaceView3D, None]:
|
||||||
if area := cls.get_view3d_area():
|
if area := cls.get_view3d_area():
|
||||||
for space in area.spaces:
|
return area.spaces.active
|
||||||
if space.type == "VIEW_3D":
|
|
||||||
return space
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_blender_prop_default_value(cls, props, prop_name: str) -> Any:
|
def get_blender_prop_default_value(cls, props, prop_name: str) -> Any:
|
||||||
|
|||||||
Reference in New Issue
Block a user