def read_from_file(mesh_obj): """ reads the skinCluster data and applies it to mesh. :param mesh_obj: <str> the mesh object to find the file from the workspace directory. :return: <dict> the skinCluster information data. """ skin_file = file_utils.get_path(file_utils.get_maya_workspace_dir(), mesh_obj) ft = file_utils.JSONSerializer(skin_file) return ft.read()
def read_blueprint(creature_name): """ reads the .JSON creature file. :param creature_name: <str> creature file name. :return: <dict> creature blueprint data. """ blueprint_file_name = get_blueprint_path(creature_name) json_file = file_utils.JSONSerializer(file_name=blueprint_file_name) return json_file.read()
def delete_blueprint(creature_name): """ removes this file and directory from disk. :return: <bool> True for success. """ blueprint_file_name = get_blueprint_path(creature_name) json_file = file_utils.JSONSerializer(file_name=blueprint_file_name) json_file.delete() delete_blueprint_dir(json_file.FILE_NAME) return True
def open_blueprint_file(creature_name): """ opens the blueprint directory :param creature_name: <str> creature name for append path. :return: <bool> True for success. """ blueprint_file_name = get_blueprint_path(creature_name) json_file = file_utils.JSONSerializer(file_name=blueprint_file_name) print("[Opening Creature File] :: {}".format(json_file)) os.startfile(json_file.file_name) return True
def save_controller_shape(controller_name): """ saves the controller shape data to file. :return: <str> controller file path name. """ curve_data = curve_utils.get_nurb_data(controller_name) controller_data_file_name = get_controller_path(controller_name) json_cls = file_utils.JSONSerializer(file_name=controller_data_file_name) json_cls.write(data=curve_data) # print("[ControllerShapeFile] :: {}".format(json_cls.file_name)) return controller_data_file_name
def write_blueprint(creature_name, data): """ writes the creature blueprint at default file path :param creature_name: <str> creature file name. :param data: <dict> creature data. :return: <bool> True for success. """ blueprint_file_name = get_blueprint_path(creature_name) json_file = file_utils.JSONSerializer(file_name=blueprint_file_name, data=data) json_file.write() return True
def get_controller_data_file(shape_name): """ get the data from shape name given. :param shape_name: :return: """ if not is_shape_in_dir(shape_name): raise IOError( "[NoControllerShapesFoundInDir] :: {}".format(shape_name)) shape_file = find_shape_in_dir(shape_name)[0] controller_data_file_name = get_controller_path(shape_file) json_cls = file_utils.JSONSerializer(file_name=controller_data_file_name) return json_cls.read()
def save_to_file(mesh_obj=''): """ writes the skinCluster data into a JSON file type. :param mesh_obj: <str> the mesh object to query the skinCluster data from. :return: <str> the written skinCluster JSON file. """ if not mesh_obj: mesh_obj = object_utils.get_selected_node() data = get_skin_data(mesh_obj) skin_file = file_utils.get_path(file_utils.get_maya_workspace_data_dir(), mesh_obj) ft = file_utils.JSONSerializer(skin_file, data) ft.write() print("Weights saved: {}\n".format(ft.FILE_NAME)) return skin_file