Add camera shift sync

This commit is contained in:
copilot-swe-agent[bot]
2026-07-02 17:46:11 +00:00
committed by GitHub
parent 00ec587296
commit da4b2f6eee
6 changed files with 132 additions and 1 deletions
+77
View File
@@ -73,6 +73,83 @@ class TestCreateCamera(NewFile):
assert obj.users_collection == tuple()
class TestImportCameraProps(NewFile):
def test_imports_perspective_camera_shifts_from_drawing_pset(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
drawing = ifc.createIfcAnnotation(ObjectType="DRAWING")
pset = ifcopenshell.api.pset.add_pset(ifc, product=drawing, name="EPset_Drawing")
ifcopenshell.api.pset.edit_pset(
ifc,
pset=pset,
properties={"PerspectiveShiftX": 0.125, "PerspectiveShiftY": -0.375},
)
camera = bpy.data.cameras.new("Camera")
camera.type = "PERSP"
subject.import_camera_props(drawing, camera)
assert camera.shift_x == pytest.approx(0.125)
assert camera.shift_y == pytest.approx(-0.375)
def test_non_perspective_import_defaults_camera_shifts_to_zero(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
drawing = ifc.createIfcAnnotation(ObjectType="DRAWING")
pset = ifcopenshell.api.pset.add_pset(ifc, product=drawing, name="EPset_Drawing")
ifcopenshell.api.pset.edit_pset(
ifc,
pset=pset,
properties={"PerspectiveShiftX": 0.125, "PerspectiveShiftY": -0.375},
)
camera = bpy.data.cameras.new("Camera")
camera.type = "ORTHO"
camera.shift_x = 1.0
camera.shift_y = -1.0
subject.import_camera_props(drawing, camera)
assert camera.shift_x == 0.0
assert camera.shift_y == 0.0
class TestSyncPerspectiveCameraShifts(NewFile):
def test_round_trips_perspective_camera_shifts_through_drawing_pset(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
drawing = ifc.createIfcAnnotation(ObjectType="DRAWING")
camera = bpy.data.cameras.new("Camera")
camera.type = "PERSP"
camera.shift_x = 0.25
camera.shift_y = -0.5
subject.sync_perspective_camera_shifts(drawing, camera)
pset = ifcopenshell.util.element.get_pset(drawing, "EPset_Drawing")
assert pset["PerspectiveShiftX"] == pytest.approx(0.25)
assert pset["PerspectiveShiftY"] == pytest.approx(-0.5)
reloaded_camera = bpy.data.cameras.new("ReloadedCamera")
reloaded_camera.type = "PERSP"
subject.import_camera_props(drawing, reloaded_camera)
assert reloaded_camera.shift_x == pytest.approx(0.25)
assert reloaded_camera.shift_y == pytest.approx(-0.5)
def test_ignores_non_perspective_camera_shifts(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
drawing = ifc.createIfcAnnotation(ObjectType="DRAWING")
camera = bpy.data.cameras.new("Camera")
camera.type = "ORTHO"
camera.shift_x = 0.25
camera.shift_y = -0.5
subject.sync_perspective_camera_shifts(drawing, camera)
assert ifcopenshell.util.element.get_pset(drawing, "EPset_Drawing") is None
class TestCreateSvgSheet(NewFile):
def test_run(self):
ifc = ifcopenshell.file()