2424from pathlib import Path
2525from types import SimpleNamespace
2626import traceback
27+ from xml .etree import ElementTree
2728
2829import bpy
2930import pymvr
@@ -69,6 +70,17 @@ def create_local_transform_property(obj):
6970 obj ["MVR Local Transform" ] = trans_mtx
7071
7172
73+ def serialize_connections_xml (connections ):
74+ if not connections or len (connections ) == 0 :
75+ return ""
76+ root = ElementTree .Element ("Root" )
77+ connections .to_xml (root )
78+ connections_node = root .find ("Connections" )
79+ if connections_node is None :
80+ return ""
81+ return ElementTree .tostring (connections_node , encoding = "unicode" )
82+
83+
7284def get_matrix (obj , mtx ):
7385 mtx_data = obj .matrix .matrix
7486 check_float = any (isinstance (i , float ) for i in set ().union (sum (mtx_data , [])))
@@ -773,6 +785,7 @@ def add_mvr_fixture(
773785 for address in fixture .addresses .addresses
774786 if address .address > 0
775787 ]
788+ connections_xml = serialize_connections_xml (fixture .connections )
776789 null_matrix = pymvr .Matrix ([[0 , 0 , 0 , 0 ], [0 , 0 , 0 , 0 ], [0 , 0 , 0 , 0 ], [0 , 0 , 0 , 0 ]])
777790 # ensure that fixture is not scaled to 0
778791 if fixture .matrix == null_matrix :
@@ -807,6 +820,8 @@ def add_mvr_fixture(
807820 classing = fixture .classing ,
808821 user_fixture_name = fixture .name ,
809822 )
823+ existing_fixture .mvr_connections_xml = connections_xml
824+ added_fixture = existing_fixture
810825 else :
811826 if isinstance (fixture .color , str ):
812827 fixture .color = pymvr .Color (str_repr = fixture .color )
@@ -829,6 +844,9 @@ def add_mvr_fixture(
829844 classing = fixture .classing ,
830845 user_fixture_name = fixture .name ,
831846 )
847+ added_fixture = dmx .findFixtureByUUID (fixture .uuid )
848+ if added_fixture :
849+ added_fixture .mvr_connections_xml = connections_xml
832850
833851 if parent_object is not None :
834852 direct_fixture_children .append (
@@ -852,7 +870,6 @@ def add_mvr_fixture(
852870 dump .append (fixture .uuid )
853871 group .dump = json .dumps (dump )
854872
855- added_fixture = dmx .findFixtureByUUID (fixture .uuid )
856873 if added_fixture :
857874 added_fixture ["layer_name" ] = layer_collection .name
858875 added_fixture ["layer_uuid" ] = layer_collection .get ("UUID" , None )
0 commit comments