def send_add_object_to_collection(client: Client, collection_name, obj_name): logger.info("send_add_object_to_collection %s <- %s", collection_name, obj_name) buffer = common.encode_string(collection_name) + common.encode_string( obj_name) client.add_command( common.Command(common.MessageType.ADD_OBJECT_TO_COLLECTION, buffer, 0))
def send_collection_instance(client: Client, obj): if not obj.instance_collection: return instance_name = obj.name_full instanciated_collection = obj.instance_collection.name_full buffer = common.encode_string(instance_name) + common.encode_string(instanciated_collection) client.add_command(common.Command(common.MessageType.INSTANCE_COLLECTION, buffer, 0))
def send_remove_object_from_scene(client: Client, scene_name: str, object_name: str): logger.info("send_remove_object_from_scene %s <- %s", scene_name, object_name) buffer = common.encode_string(scene_name) + common.encode_string( object_name) client.add_command( common.Command(common.MessageType.REMOVE_OBJECT_FROM_SCENE, buffer, 0))
def send_object_visibility(client: Client, object_: bpy.types.Object): logger.debug("send_object_visibility %s", object_.name_full) buffer = (common.encode_string(object_.name_full) + common.encode_bool(object_.hide_viewport) + common.encode_bool(object_.hide_select) + common.encode_bool(object_.hide_render) + common.encode_bool(object_.hide_get())) client.add_command( common.Command(common.MessageType.OBJECT_VISIBILITY, buffer, 0))
def send_remove_object_from_collection(client: Client, collection_name, obj_name): logger.info("send_remove_object_from_collection %s <- %s", collection_name, obj_name) buffer = common.encode_string(collection_name) + common.encode_string( obj_name) client.add_command( common.Command(common.MessageType.REMOVE_OBJECT_FROM_COLLECTION, buffer, 0))
def send_add_collection_to_scene(client: Client, scene_name: str, collection_name: str): logger.info("send_add_collection_to_scene %s <- %s", scene_name, collection_name) buffer = common.encode_string(scene_name) + common.encode_string( collection_name) client.add_command( common.Command(common.MessageType.ADD_COLLECTION_TO_SCENE, buffer, 0))
def send_remove_collection_from_scene(client: Client, scene_name: str, collection_name: str): logger.info("send_remove_collection_from_scene %s <- %s", scene_name, collection_name) buffer = common.encode_string(scene_name) + common.encode_string( collection_name) client.add_command( common.Command(common.MessageType.REMOVE_COLLECTION_FROM_SCENE, buffer, 0))
def send_collection(client: Client, collection: bpy.types.Collection): logger.info("send_collection %s", collection.name_full) collection_instance_offset = collection.instance_offset temporary_visibility = True layer_collection = share_data.blender_layer_collections.get( collection.name_full) if layer_collection: temporary_visibility = not layer_collection.hide_viewport buffer = (common.encode_string(collection.name_full) + common.encode_bool(not collection.hide_viewport) + common.encode_vector3(collection_instance_offset) + common.encode_bool(temporary_visibility)) client.add_command(common.Command(common.MessageType.COLLECTION, buffer, 0))
def send_grease_pencil_mesh(client: Client, obj): grease_pencil = obj.data buffer = common.encode_string(grease_pencil.name_full) buffer += common.encode_int(len(grease_pencil.materials)) for material in grease_pencil.materials: if not material: material_name = "Default" else: material_name = material.name_full buffer += common.encode_string(material_name) buffer += common.encode_int(len(grease_pencil.layers)) for name, layer in grease_pencil.layers.items(): buffer += send_grease_pencil_layer(layer, name) client.add_command(common.Command(common.MessageType.GREASE_PENCIL_MESH, buffer, 0)) send_grease_pencil_time_offset(client, obj)
def send_grease_pencil_time_offset(client: Client, obj): grease_pencil = obj.data buffer = common.encode_string(grease_pencil.name_full) for modifier in obj.grease_pencil_modifiers: if modifier.type != "GP_TIME": continue offset = modifier.offset scale = modifier.frame_scale custom_range = modifier.use_custom_frame_range frame_start = modifier.frame_start frame_end = modifier.frame_end buffer += (common.encode_int(offset) + common.encode_float(scale) + common.encode_bool(custom_range) + common.encode_int(frame_start) + common.encode_int(frame_end)) client.add_command( common.Command(common.MessageType.GREASE_PENCIL_TIME_OFFSET, buffer, 0)) break
def send_grease_pencil_material(client: Client, material): gp_material = material.grease_pencil stroke_enable = gp_material.show_stroke stroke_mode = gp_material.mode stroke_style = gp_material.stroke_style stroke_color = gp_material.color stroke_overlap = gp_material.use_overlap_strokes fill_enable = gp_material.show_fill fill_style = gp_material.fill_style fill_color = gp_material.fill_color gp_material_buffer = common.encode_string(material.name_full) gp_material_buffer += common.encode_bool(stroke_enable) gp_material_buffer += common.encode_string(stroke_mode) gp_material_buffer += common.encode_string(stroke_style) gp_material_buffer += common.encode_color(stroke_color) gp_material_buffer += common.encode_bool(stroke_overlap) gp_material_buffer += common.encode_bool(fill_enable) gp_material_buffer += common.encode_string(fill_style) gp_material_buffer += common.encode_color(fill_color) client.add_command(common.Command(common.MessageType.GREASE_PENCIL_MATERIAL, gp_material_buffer, 0))
def send_light(client: Client, obj): logger.info("send_light %s", obj.name_full) light_buffer = get_light_buffer(obj) if light_buffer: client.add_command( common.Command(common.MessageType.LIGHT, light_buffer, 0))
def send_grease_pencil_connection(client: Client, obj): buffer = common.encode_string(get_object_path(obj)) buffer += common.encode_string(obj.data.name_full) client.add_command( common.Command(common.MessageType.GREASE_PENCIL_CONNECTION, buffer, 0))
def send_add_constraint(client: Client, object_: bpy.types.Object, constraint_type: ConstraintType, target: str): buffer = common.encode_int(constraint_type) + common.encode_string( object_.name_full) + common.encode_string(target) client.add_command( common.Command(common.MessageType.ADD_CONSTRAINT, buffer, 0))
def send_remove_constraints(client: Client, object_: bpy.types.Object, constraint_type: ConstraintType): buffer = common.encode_int(constraint_type) + common.encode_string( object_.name_full) client.add_command( common.Command(common.MessageType.REMOVE_CONSTRAINT, buffer, 0))
def send_empty(client: Client, obj): path = get_object_path(obj) buffer = common.encode_string(path) if buffer: client.add_command(common.Command(common.MessageType.EMPTY, buffer, 0))
def send_add_object_to_scene(client: Client, scene_name: str, obj_name: str): logger.info("send_add_object_to_scene %s <- %s", scene_name, obj_name) buffer = common.encode_string(scene_name) + common.encode_string(obj_name) client.add_command( common.Command(common.MessageType.ADD_OBJECT_TO_SCENE, buffer, 0))
def send_add_object_to_vrtist(client: Client, scene_name: str, obj_name: str): logger.debug("send_add_object_to_vrtist %s <- %s", scene_name, obj_name) buffer = common.encode_string(scene_name) + common.encode_string(obj_name) client.add_command( common.Command(common.MessageType.ADD_OBJECT_TO_VRTIST, buffer, 0))
def send_scene_renamed(client: Client, old_name: str, new_name: str): logger.info("send_scene_renamed %s to %s", old_name, new_name) buffer = common.encode_string(old_name) + common.encode_string(new_name) client.add_command( common.Command(common.MessageType.SCENE_RENAMED, buffer, 0))
def send_camera(client: Client, obj): camera_buffer = get_camera_buffer(obj) if camera_buffer: client.add_command(common.Command(common.MessageType.CAMERA, camera_buffer, 0))
def send_collection_removed(client: Client, collection_name): logger.info("send_collection_removed %s", collection_name) buffer = common.encode_string(collection_name) client.add_command( common.Command(common.MessageType.COLLECTION_REMOVED, buffer, 0))
def send_scene(client: Client, scene_name: str): logger.info("send_scene %s", scene_name) buffer = common.encode_string(scene_name) client.add_command(common.Command(common.MessageType.SCENE, buffer, 0))