mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 19:09:07 +00:00
typing
This commit is contained in:
@@ -1283,6 +1283,7 @@ class ActivateBcfViewpoint(bpy.types.Operator):
|
|||||||
cam_aspect: float,
|
cam_aspect: float,
|
||||||
context: bpy.types.Context,
|
context: bpy.types.Context,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
assert isinstance(obj.data, bpy.types.Camera)
|
||||||
if viewpoint.visualization_info.orthogonal_camera:
|
if viewpoint.visualization_info.orthogonal_camera:
|
||||||
camera = viewpoint.visualization_info.orthogonal_camera
|
camera = viewpoint.visualization_info.orthogonal_camera
|
||||||
obj.data.type = "ORTHO"
|
obj.data.type = "ORTHO"
|
||||||
|
|||||||
@@ -392,6 +392,7 @@ ground_glow source ground
|
|||||||
scene.add_surface(scene_path)
|
scene.add_surface(scene_path)
|
||||||
scene.add_source(sky_file_path)
|
scene.add_source(sky_file_path)
|
||||||
print("Setting up view...")
|
print("Setting up view...")
|
||||||
|
assert isinstance(camera.data, bpy.types.Camera)
|
||||||
if camera.data.type == "PERSP":
|
if camera.data.type == "PERSP":
|
||||||
# Perspective camera
|
# Perspective camera
|
||||||
camera_fov = camera.data.angle
|
camera_fov = camera.data.angle
|
||||||
@@ -547,9 +548,11 @@ class ViewFromSun(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if not (camera := bpy.data.objects.get("SunPathCamera")):
|
if not (camera := bpy.data.objects.get("SunPathCamera")):
|
||||||
camera = bpy.data.objects.new("SunPathCamera", bpy.data.cameras.new("SunPathCamera"))
|
camera = bpy.data.objects.new("SunPathCamera", bpy.data.cameras.new("SunPathCamera"))
|
||||||
|
assert isinstance(camera.data, bpy.types.Camera)
|
||||||
|
assert context.scene
|
||||||
camera.data.type = "ORTHO"
|
camera.data.type = "ORTHO"
|
||||||
camera.data.ortho_scale = 100 # The default of 6m is too small
|
camera.data.ortho_scale = 100 # The default of 6m is too small
|
||||||
bpy.context.scene.collection.objects.link(camera)
|
context.scene.collection.objects.link(camera)
|
||||||
tool.Blender.activate_camera(camera)
|
tool.Blender.activate_camera(camera)
|
||||||
props = context.scene.BIMSolarProperties
|
props = context.scene.BIMSolarProperties
|
||||||
props.hour = props.hour # Just to refresh camera position
|
props.hour = props.hour # Just to refresh camera position
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class LoadsDecorator:
|
|||||||
|
|
||||||
coord = Vector(coord)
|
coord = Vector(coord)
|
||||||
rv3d = context.region_data
|
rv3d = context.region_data
|
||||||
|
assert rv3d and context.region
|
||||||
perspective = rv3d.view_perspective
|
perspective = rv3d.view_perspective
|
||||||
view_matrix = rv3d.view_matrix
|
view_matrix = rv3d.view_matrix
|
||||||
point_view_space = view_matrix @ coord
|
point_view_space = view_matrix @ coord
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
cls, context: bpy.types.Context, obj: bpy.types.Object
|
cls, context: bpy.types.Context, obj: bpy.types.Object
|
||||||
) -> Union[tuple[bpy.types.Object, list[float]], None]:
|
) -> Union[tuple[bpy.types.Object, list[float]], None]:
|
||||||
rv3d = context.region_data
|
rv3d = context.region_data
|
||||||
|
assert rv3d
|
||||||
view_location = rv3d.view_matrix.inverted().translation
|
view_location = rv3d.view_matrix.inverted().translation
|
||||||
obj_matrix = obj.matrix_world.copy()
|
obj_matrix = obj.matrix_world.copy()
|
||||||
bbox = [obj_matrix @ Vector(v) for v in obj.bound_box]
|
bbox = [obj_matrix @ Vector(v) for v in obj.bound_box]
|
||||||
@@ -138,6 +139,7 @@ class Raycast(bonsai.core.tool.Raycast):
|
|||||||
):
|
):
|
||||||
region = context.region
|
region = context.region
|
||||||
rv3d = context.region_data
|
rv3d = context.region_data
|
||||||
|
assert rv3d and region
|
||||||
original_perspective = rv3d.view_perspective
|
original_perspective = rv3d.view_perspective
|
||||||
|
|
||||||
# TODO The raycast was working for orthographic view, but not when you are inside a camera view. This solution feels hacky,
|
# TODO The raycast was working for orthographic view, but not when you are inside a camera view. This solution feels hacky,
|
||||||
|
|||||||
@@ -1666,9 +1666,11 @@ class Sequence(bonsai.core.tool.Sequence):
|
|||||||
return predefined_type, object_type
|
return predefined_type, object_type
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_animation_camera(cls):
|
def add_animation_camera(cls) -> None:
|
||||||
bpy.ops.object.camera_add()
|
bpy.ops.object.camera_add()
|
||||||
camera = bpy.context.active_object
|
camera = bpy.context.active_object
|
||||||
|
assert camera and isinstance(camera.data, bpy.types.Camera)
|
||||||
|
assert bpy.context.scene
|
||||||
camera.data.lens = 26
|
camera.data.lens = 26
|
||||||
camera.name = "4D Camera"
|
camera.name = "4D Camera"
|
||||||
camera.location = mathutils.Vector((15, 0, 15))
|
camera.location = mathutils.Vector((15, 0, 15))
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.unit
|
||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
from bonsai.bim.module.model.decorator import PolylineDecorator
|
from bonsai.bim.module.model.decorator import PolylineDecorator
|
||||||
@@ -44,8 +45,9 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
cls.snap_plane_method = value
|
cls.snap_plane_method = value
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_increment_snap_value(cls, context):
|
def get_increment_snap_value(cls, context: bpy.types.Context) -> Union[float, None]:
|
||||||
rv3d = context.region_data
|
rv3d = context.region_data
|
||||||
|
assert rv3d
|
||||||
|
|
||||||
factor = 1
|
factor = 1
|
||||||
fractions = [100, 20, 10, 2]
|
fractions = [100, 20, 10, 2]
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class TestCreateCamera(NewFile):
|
|||||||
obj = subject.create_camera("Name", mathutils.Matrix(), "PERSPECTIVE")
|
obj = subject.create_camera("Name", mathutils.Matrix(), "PERSPECTIVE")
|
||||||
assert obj.name == "Name"
|
assert obj.name == "Name"
|
||||||
assert obj.matrix_world == mathutils.Matrix()
|
assert obj.matrix_world == mathutils.Matrix()
|
||||||
|
assert isinstance(obj.data, bpy.types.Camera)
|
||||||
assert obj.data.type == "PERSP"
|
assert obj.data.type == "PERSP"
|
||||||
assert obj.data.ortho_scale == 50
|
assert obj.data.ortho_scale == 50
|
||||||
assert obj.data.clip_end == 10
|
assert obj.data.clip_end == 10
|
||||||
|
|||||||
Reference in New Issue
Block a user