Skip to content

Commit e236bbb

Browse files
committed
Use GDTF spec in mvr
1 parent 4fb9cb7 commit e236bbb

1 file changed

Lines changed: 70 additions & 2 deletions

File tree

‎mvr.py‎

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def get_child_list_steps(
297297
import_globals,
298298
layer_collection,
299299
parent_blender_object,
300+
mvr_layer_collection=layer_collection,
300301
)
301302
yield _yield_import_step("truss", truss_obj)
302303

@@ -330,6 +331,7 @@ def get_child_list_steps(
330331
import_globals,
331332
layer_collection,
332333
parent_blender_object,
334+
mvr_layer_collection=layer_collection,
333335
)
334336
yield _yield_import_step("projector", projector_obj)
335337

@@ -363,6 +365,7 @@ def get_child_list_steps(
363365
import_globals,
364366
layer_collection,
365367
parent_blender_object,
368+
mvr_layer_collection=layer_collection,
366369
)
367370
yield _yield_import_step("support", support_obj)
368371

@@ -396,6 +399,7 @@ def get_child_list_steps(
396399
import_globals,
397400
layer_collection,
398401
parent_blender_object,
402+
mvr_layer_collection=layer_collection,
399403
)
400404
yield _yield_import_step("video screen", video_obj)
401405

@@ -429,6 +433,7 @@ def get_child_list_steps(
429433
import_globals,
430434
layer_collection,
431435
parent_blender_object,
436+
mvr_layer_collection=layer_collection,
432437
)
433438
yield _yield_import_step("scene object", scene_obj)
434439

@@ -584,6 +589,7 @@ def process_mvr_object(
584589
import_globals,
585590
group_collect,
586591
parent_blender_object=None,
592+
mvr_layer_collection=None,
587593
):
588594
uid = mvr_object.uuid
589595
name = mvr_object.name
@@ -695,6 +701,58 @@ def add_mvr_object(idx, node, mtx, collect, file=""):
695701
dmx_mvr_object.object_type = mvr_object.__class__.__name__
696702
dmx_mvr_object.collection = bpy.data.collections.new(mvr_object.uuid)
697703

704+
# Some MVR object types can carry both a Symbol and a GDTF reference. A
705+
# GDTF is the authoritative representation in that case. Import it as a
706+
# regular BlenderDMX fixture and only use the Symbol path below when no
707+
# usable GDTF is present.
708+
gdtf_spec = (getattr(mvr_object, "gdtf_spec", None) or "").strip()
709+
if gdtf_spec:
710+
gdtf_object = SimpleNamespace(
711+
name=name,
712+
uuid=uid,
713+
gdtf_spec=gdtf_spec,
714+
gdtf_mode=getattr(mvr_object, "gdtf_mode", None),
715+
matrix=mvr_object.matrix,
716+
classing=classing,
717+
addresses=pymvr.Addresses(),
718+
color=pymvr.Color(str_repr="0.312712,0.329008,100.000000"),
719+
connections=None,
720+
protocols=None,
721+
fixture_id="",
722+
custom_id=0,
723+
fixture_id_numeric=0,
724+
unit_number=0,
725+
focus=None,
726+
)
727+
added_fixture = add_mvr_fixture(
728+
dmx,
729+
mscale,
730+
mvr_scene,
731+
os.path.join(current_path, "assets", "profiles"),
732+
gdtf_object,
733+
mvr_idx,
734+
0,
735+
[],
736+
import_globals,
737+
fallback_profile=None,
738+
)
739+
if added_fixture is not None:
740+
layer = mvr_layer_collection or group_collect
741+
added_fixture["layer_name"] = layer.name
742+
added_fixture["layer_uuid"] = layer.get("UUID", None)
743+
if parent_blender_object is not None:
744+
root_object = next(
745+
(
746+
fixture_object.object
747+
for fixture_object in added_fixture.objects
748+
if fixture_object.name == "Root"
749+
),
750+
None,
751+
)
752+
if root_object is not None:
753+
root_object.parent = parent_blender_object
754+
return
755+
698756
if isinstance(mvr_object, pymvr.Symbol):
699757
symbols.append(mvr_object)
700758
elif isinstance(mvr_object, pymvr.Geometry3D):
@@ -905,6 +963,7 @@ def add_mvr_fixture(
905963
fixture_group=None,
906964
parent_object=None,
907965
layer_collection=None,
966+
fallback_profile="BlenderDMX@RysyParLED@version7.gdtf",
908967
):
909968
"""Add fixture to the scene"""
910969

@@ -926,7 +985,9 @@ def add_mvr_fixture(
926985
DMX_Log.log.error(
927986
f"{fixture.gdtf_spec} not in mvr_scene._package.namelist, using a generic PAR"
928987
)
929-
fixture.gdtf_spec = "BlenderDMX@RysyParLED@version7.gdtf"
988+
if fallback_profile is None:
989+
return None
990+
fixture.gdtf_spec = fallback_profile
930991
for address in fixture.addresses.addresses:
931992
dmx.ensureUniverseExists(address.universe)
932993

@@ -1006,7 +1067,12 @@ def add_mvr_fixture(
10061067
use_high_mesh=import_globals.use_high_mesh,
10071068
)
10081069
except:
1009-
fixture.gdtf_spec = "BlenderDMX@RysyParLED@version7.gdtf"
1070+
if fallback_profile is None:
1071+
DMX_Log.log.exception(
1072+
f"Unable to import GDTF for MVR object {fixture.name}"
1073+
)
1074+
return None
1075+
fixture.gdtf_spec = fallback_profile
10101076

10111077
dmx.addFixture(
10121078
fixture.gdtf_spec,
@@ -1097,6 +1163,8 @@ def add_mvr_fixture(
10971163
focus_fixture.collection,
10981164
)
10991165

1166+
return added_fixture
1167+
11001168

11011169
def perform_direct_parenting(dmx):
11021170
for item in direct_fixture_children:

0 commit comments

Comments
 (0)