@@ -539,6 +539,12 @@ def RecordObjectOutputToJSON(objects_sets_dict, the_object, is_instance: bool,
539539 inst_pos , inst_rot , inst_scale = the_object .matrix_world .decompose ()
540540 js_object_data ["Transforms" ].append ((tuple (inst_pos ), tuple (inst_rot .to_euler ('XYZ' )), tuple (inst_scale )))
541541
542+ # Get Custom Attributes
543+ custom_attribs_dict = GetCustomAttribs ("bei_" , mesh .attributes )
544+ if custom_attribs_dict :
545+ js_object_data [BESettings .CUSTOM_ATTRIBUTES ] = custom_attribs_dict
546+
547+
542548 # Get Mesh or BENGINE_INSTANCE
543549 if obj_type == "MESH" :
544550 # Get BENGINE_INSTANCE Value
@@ -549,7 +555,7 @@ def RecordObjectOutputToJSON(objects_sets_dict, the_object, is_instance: bool,
549555 be_inst_id = mesh .attributes [BESettings .BENGINE_INSTANCE ].data [0 ].value
550556
551557 if type (be_inst_id ) is int :
552- js_object_data [BESettings .KEYPARAM_BE_INSTANCE ] = be_inst_id
558+ js_object_data [BESettings .OUT_BE_INSTANCE ] = be_inst_id
553559 else :
554560 print (BESettings .BENGINE_INSTANCE + " Attribute is not Integer!!!" )
555561
@@ -568,6 +574,51 @@ def RecordObjectOutputToJSON(objects_sets_dict, the_object, is_instance: bool,
568574 js_object_data ["Mesh" ] = meshes_tmp_list .index (mesh )
569575
570576
577+ # Get Custom Instance Attributes
578+ def GetCustomAttribs (custom_attrib_name : str , attributes ):
579+ custom_attribs_dict = {}
580+
581+ float_custom_attribs = {}
582+ vector_custom_attribs = {}
583+ color_custom_attribs = {}
584+
585+ for attrib_name in attributes .keys ():
586+ if attrib_name .startswith (custom_attrib_name ):
587+ attrib = attributes [attrib_name ].data [0 ]
588+
589+ GetCustomAttrib (attrib , float_custom_attribs , vector_custom_attribs , color_custom_attribs , attrib_name )
590+
591+ # Add Custom Attributes
592+ if float_custom_attribs or vector_custom_attribs or color_custom_attribs :
593+ if float_custom_attribs :
594+ custom_attribs_dict [BESettings .CUSTOM_FLOAT_ATTRIBS ] = float_custom_attribs
595+
596+ if vector_custom_attribs :
597+ custom_attribs_dict [BESettings .CUSTOM_VECTOR_ATTRIBS ] = vector_custom_attribs
598+
599+ if color_custom_attribs :
600+ custom_attribs_dict [BESettings .CUSTOM_COLOR_ATTRIBS ] = color_custom_attribs
601+
602+ return custom_attribs_dict
603+
604+
605+ def GetCustomAttrib (attrib , float_attribs : dict , vector_attribs : dict , color_attribs : dict , attrib_name : str ):
606+ attrib_type = type (attrib )
607+ attrib_val = None
608+
609+ if (attrib_type is bpy .types .FloatVectorAttributeValue ):
610+ attrib_val = attrib .vector
611+ vector_attribs [attrib_name ] = tuple (attrib_val )
612+
613+ elif (attrib_type is bpy .types .FloatColorAttributeValue or attrib_type is bpy .types .ByteColorAttributeValue ):
614+ attrib_val = attrib .color
615+ color_attribs [attrib_name ] = tuple (attrib_val )
616+
617+ else :
618+ attrib_val = attrib .value
619+ float_attribs [attrib_name ] = attrib_val
620+
621+
571622def GetBlenderOutputs (context , process_objs : list , engine_type : EngineType , is_GN : bool ):
572623
573624 depsgraph = context .evaluated_depsgraph_get ()
0 commit comments