Objective
Learn variables used in Python Script API.
※Note:
- Location of Example File:
- CLO install folder
- CLO install folder
- How to Execute Example File:
-
Please type below text in Script Console
-
py> import example
-
py> from example import *
-
py> exam = example()
-
py> exam.function(mdsa)
-
Function is example, please find usable function from example.py file.
-
mdsa is python module allows to use functions of CLO from python.
-
Operation
- Open Python Script.
- When the Python Script console appears, type in desired API.
API
#mdsa = CLO Script API
Variable
Variable name |
Type |
Explication |
---|---|---|
open_avatar_file_list |
String List |
List type Variable, designate directory of Avatar files want to open. |
open_garment_file_list |
String List |
List type Variable, designate directory of Garment files want to open. |
open_animation_file_list |
String List |
List type Variable, designate directory of Animation files want to open. |
save_file_path_list |
String List |
List type Variable, designate directory and name of files will be saved. |
obj_type_list |
Integer List |
List type Variable, saves Type of Avatar want to use. |
simulation_quality_list |
Integer List |
List type Variable, designate Simulation Quality. |
simulation_delay_time_list |
Integer List |
List type Variable, designate time of default pose Simulation. |
export_scale_unit |
String |
Variable, designate scale of object by unit when exporting. |
export_fps |
Integer |
Variable, designate fps of object when exporting. |
unified_map |
Boolean |
Variable, decide whether unify UV or not when exporting. |
import_scale_unit |
String |
Variable, designate scale of object by unit when importing. |
import_fps |
Integer |
Variable, designate fps of object when importing. |
current_process |
Integer |
‘Process’ represent a flow of ‘file open -> simulation-> Animation -> Saving file’. Multiple ‘Process’ can be calculated at the same time. We do not recommend to access this variable. |
save_folder_path |
String |
Variable designates save folder |
module_obj |
CLO Module |
Internal API module of CLO. We do recommend not to access this variable. |
Function
def initialize(object):
- Reset mdsa object currently use.
def clear_console(object):
- Clear console window.
def get_split_string(object, string, split_filter_list):
- String = string type, split_filter_list = string list type
- This function returns a string list (string list = source string / split_filter_list. Split_filter_list is the list of standard string for split. get_split_string function split Split_filter_list from first string. If the string is not available to split by first string (If a character is not included in string) It Sequentially look up next string. If it find a string which can be split from split_filter_list, it returns split string list. If it could not find a string which can be split, it will return empty string list. Split_filter character will be excluded from string list.
- get_split_string(“C:\Users\Public\Documents\CLO\Assets_ver_3.0.9999\default.zpac”, [“\\”, “/”])
- [“C:”, “Users”, “Public”, “Documents”, “CLO”, “Assets_ver_3.0.9999”, “default.zpac”]
def get_file_name(object, file_path):
- file_path is string type
- This function only returns file_name which received from file_path as a factor.
- get_file_name(“C:\Users\Public\Documents\CLO\Assets_ver_3.0.9999\default.zpac”)
- default.zpac”
def get_filter_file_name(object, file_list, filter):
- file_list is string list type, filter is string type
- This function returns list of files with certain extension which received as a factor from file_list. It is case insensitive when look up extension of files.
def make_valid_folder_path(object, folder_path):.
- Folder_path is string type
- If the last letter of path is not “\” or “/”, it is recognized as invalid path. This function changes an invalid path to the valid form and return.
def get_entry_list(object, folder_path):
- Folder_path is string type
- get_entry_list returns a list of file from Folder_path.
def set_open_option(object, unit = "none", fps = 30):
- Unit is string type, allows you to set unit value as "cm", "mm", "inch", "feet", "m". default value is "mm".
- Fps is integer type, default is 30 fps.
- set_open_option designates import options of obj, cache, fbx and alembic file. In case you need to import multiple files and want to set different options, please use set_open_option_list function. This function only decides values. To apply this value to CLO, must call set_app_open_option function.
def set_save_option(object, unit = "none", fps = 30, unified = False):
- unit is string type allows you to set unit value as "cm", "mm", "inch", "feet", "m". default is "mm".
- Fps is integer type, default is 30 fps
- Unified is Boolean type, when it is True, it changes value of object’s UV from 0 to 1. Default is False.
- Setting export option of obj, cache, fbx, alembic and Garment file. In case you need to export multiple files and want to set different options, please use set_save_option_list function. This function only decides values. To apply this value to CLO, must call set_app_save_option function.
def set_open_option_list(object, unit_list, fps_list):
- unit_list is string list type, fps_list is integer list type
- Setting import option for obj, cache, fbx, alembic and Garment file. In case you need to import multiple files and want to set different options, call this function. The factor is list type and the factor unit_list and fps_list must be the same count. If there are more files to import than option_list, values will be set the same as the last items. Please refer to example.py for details.
def set_save_option_list(object, unit_list, fps_list, unified_map_list):
- unit_list is string list type, fps_list is integer list type, unified_map_list is Boolean list type
- Setting export option for obj, cache, fbx, Alembic and Garment file. In case you need to export multiple files and want to set different options, call this function. The factor is list type and the factor unit_list, fps_list, unified_map_list must be the same count. If there are more files to export than option_list, values will be set the same as the last items. Please refer to example.py for details.
def run_app_open_option(object):
- run_app_open_option apply values which saved at set_open_option function and designates import option of CLO.
def run_app_save_option(object):
- run_app_save_option apply values which saved at set_save_option, it designates export option of CLO.
def run_app_open_option(object, index):
- index is integer type
- This function apply value which saved at set_open_option_list, it designates export option of CLO.
- If option is set list at set_open_option_list, it send index of designated items to factor. Minimum value of Index is -0 and total list size value of -1 is the maximum value of index.
def run_app_save_option(object, index):
- Index is integer type
- Function apply value which saved at set_save_option_list function. It designates Export of CLO. If option is saved at set_save_option_list as a list, it will save option values and send it as factor and apply to items you want. Minimum value of Index is 0. The maximum value is total list size of -1.
def get_app_open_optin_count(object):
- Returns current setting of import option count. Default is 0.
def get_app_save_optin_count(object):
- Returns current setting of export option count. Default is 0.
def set_avatar_file_path(object, open_avatar_file_path):
- open_avatar_file_path is string type.
- Add avatar file path. If the count does not match with other files, the last avatar file path will be loaded.
def set_avatar_file_path_list(object, open_avatar_file_path_list):
- open_avatar_file_path_list is string list type
- Set avatar file list. It is used to set external list type value. If the count does not match with other file lists, the last avatar file path will be loaded.
def set_garment_file_path(object, open_garment_file_path):
- open_garment_file_path is string type
- Add garment file path. . If the count does not match with other files, the last garment file path will be loaded.
def set_garment_file_path_list(object, open_garment_file_path_list):
- open_garment_file_path_list is string list type
- Sets garment file list. It is used to set external list type value. If the count does not match with other file lists, the last garment file path will be loaded.
def set_animation_file_path(object, open_animation_file_path):
- open_animation_file_path is string list type
- Sets animation file list. It is used to set external list type value. If the count does not match with other file lists, the last animation file path will be loaded.
def set_animation_file_path_list(object, open_animation_file_path_list):
- open_animation_file_path_list is string list type
- Sets animation file list. It is used to set external list type value. If the count does not match with other file lists, the last animation file path will be loaded.
- def set_simulation_options(object, obj_type = 0, simulation_quality = 0, simulation_delay_time = 5000, process_simulation = True):
- obj_type is integer type, it loads object depends its value obj_type = 0 is avatar, if it is 1 trim object, if it is 2 obj to garment. Default is avatar type.
- Simulation_quality is integer type, it defines simulation quality by value 0 = Normal, 1 = complete, 2 = Custom type. Default is Normal.
- Simulation_delay_time is integer type, this Value represents the time of simulation before animation for stabilization. Default is 5000 micro seconds, (micro seconds = seconds*1000)
- Process_simulation is boolean type, this decides whether proceed simulation. Default is True.
- This function Adds Import options related to obj type and simulation. If the count does not match with files which will be imported or option is not set, value will be set to default.
def avatar_file_open(object, open_file_path, obj_type = 0, scale = "mm", fps = 30):
- open_file_path is string type, obj_type is string type, scale is string type, fps is integer type
- This function loads avatar files (avt, obj, fbx, alembic) located in open_file_path. Also applies saved obj_type, scale, fps option.
def garment_file_open(object, open_file_path):
- open_file_path is string type,
- This function loads garment (zpac, pac, zprj) file located in open_file_path.
def animation_file_open(object, open_file_path, scale = "mm", fps = 30):
- open_file_path is string type, scale is string type, fps is integer type
- This function loads animation (pos, mc, mcx, pc2, mdd) located in open_file_path file. Also applies saved scale, fps option.
def save_file_stand_alone(object, file_path, scale = "mm", fps = 30, unfined_map = True):
- File_path is string type, scale is string type, fps is integer type, unified_map은 Boolean type
- This function saves loaded files to file_path. It automatically designates file type depends on extension saved in File_path when saving. Also applies saved scale, fps, unified_map option.
def SimulationOn(object, time):
- Time is integer type, micro seconds (seconds * 1000)
- Start simulation after designated time.
def SimulationOff(object, time):
- Time is integer type, micro seconds (seconds * 1000)
- Stop simulation after designated time.
def StartAnimationRecord(object, time):
- Time is integer type, micro seconds (seconds * 1000)
- After designated time, start and record Animation.
def set_save_file_path(object, save_file_path):
- save_file_path is string type
- This function add path which received from factor to save_file_path_list. save_file_path_list need to be match at least one of saved import file list.
- This can be replaced by setting set_save_folder_path. Either of one must be set.
def set_save_folder_path(object, save_folder_path):
- save_folder_path is string type
- This function sets the path which received from factor as save folder path. Save folder path save files as Zprj. The name of file will be the same with import file list which have largest count. This can be replaced by setting set_save_file_path. Either of one must be set.
def set_garment_folder(object, garment_folder_path, filter = "zpac"):
- garment_folder_path is string type, filter is string type
- This function loads garment files from designated folder and set by open_garment_file_list. In case setting Filter value, it sets open_garment_file_list by extension which saved at filter.
- Default setting of Filter is “zpac”.
def set_avatar_folder(object, avatar_folder_path, filter = "avt"):
- avatar_folder_path is string type, filter is string type
- This function loads avatar files from designated folder and set by open_avatar_file_list로. In case setting Filter value, it sets open_avatar_file_list by extension which saved at filter. (?)
- Default setting of Filter is “avt”.
def set_animation_folder(object, animation_folder_path, filter = "pos"):
- animation_folder_path는 string type, filter는 string type
- This function loads animation files from designated folder and set by open_animation_file_list. In case setting Filter value, it sets open_animation_file_list by extension which saved at filter.
- Default setting of Filter is “pos”.
def get_max_count(object):
- This function returns the item count of the biggest size list among file lists which will be opened.
def set_auto_save(object, bAutosave) :
- This function decides whether CLO Project file (Zprj) is saved.
- If bAutoSave is True, Project (Zprj)file will be saved as the same name with the file you export as a specific format.
- Default status of Autosave is 'True'.
def on_save_zprj_with_metadata_info(object, bWith_meta_data, image_number, save_type):
- bWith_meta_data is a boolean type and stores metadata together if it is true.
- image_number is the number of snapshots in the scene to be saved. image rotates 360 degrees and stores the snapshot. The angle of rotation for each snapshot is determined by image_number / 360. It only works if with_meta_data is True.
- The save type determines how meta_data is stored. If set to 0, create a folder with the same name as the project file to be saved, and save the xml file and images under the folder. 1, all meta data will be compressed and stored as a zip file.
- Save Metadata when saving Zprj. Please refer to manual for more info about Metadata.
def on_export_garment_only(object):
- This function sets only Garments to be exported from the Scene.
def on_export_garment_with_relative_objects_only(object):
- This function sets all Scene objects to be exported except Avatar.
def on_export_avatar_only(object):
- This function allows you to export only avatars from the Scene.
def on_export_piping_pattern_only(object):
- This function sets only the piping pattern of the scene to be exported.
def on_export_zipper_teeth_pattern_only(object):
- This function sets only the zipper teeth pattern of the scene to be exported.
def on_export_trim_only(object):
- This function sets only trim to be exported from the scene.
def on_export_graphics_only(object):
- This function sets only graphics to be exported from the scene.
def on_export_zipper_puller_and_slider_only(object):
- This function sets only the zipper puller and the slider of the entire scene to be exported.
def on_export_button_hole_only(object):
- This function sets the only buttonhole to be exported from the scene.
def on_export_button_head_only(object):
- This function sets only the button head of the scene to be exported.
def on_export_obj_stitch_only(object):
- This function sets only stitch to be exported from the scene.
Note. if export_(something)_only option is not set, all object will be exported. These options only work with obj export.
def on_export_single_object(object):
- This function sets merge entire mesh into one mesh and export.
- This function can not be used at the same time with on_export_multi_object function. If it is used at the same time, it is set to the last used function.
def on_export_multi_object(object):
- This function sets to export entire mesh in the scene as the individual mesh.
- This function can not be used at the same time with on_export_single_object function. If it is used at the same time, it is set to the last used function.
def on_export_save_with_texture(object):
- This function set to export texture and export file as a zip file.
def on_export_diffuse_color_combined(object):
- This function set to save texture image and diffuse color designated to the garment as one image.
def on_export_exclude_ambient_color(object):
- This function sets the material to be saved except the Ambient value among the color values set in the garment.
def on_export_include_inner_shape(object):
- This function sets the information of the inner shape included in the garment to be saved together.
def on_export_save_meta_data(object):
- This function set to export with Metadata. Please refer to manual for more info about Metadata.
def set_export_unified_uv_texcoordnate(object, bTexture_bake, texture_bake_size, fill_texture_seam):
- bTexture_bake exports as an image. texture_bake_size determines the resolution of the texture to be saved when the btexture_bake option is set to True. min - max is 100 - 10000 pixelon_export_zipper_teeth_pattern_only and sets the width and height of the image to the designated size.
- This function sets multiple textures to be saved as an image.
- CLO uses texture coordinates and does not use normal UV (0 - 1) coordinates. This function can be set to convert UVs between 0-1 when exporting.
def set_export_axis_x(object, axis):
- axis can be set to string type "Y" or "Z". axis is not case-sensitive.
def set_export_axis_y(object, axis):
- axis can be set to string type "X" or "Z". axis is not case-sensitive.
def set_export_axis_z(object, axis):
- axis can be set to string type "X" or "Y". axis is not case-sensitive.
def on_export_invert_x(object):
- This function sets the x axis to invert.
def on_export_invert_y(object):
- This function sets the y axis to invert.
def on_export_invert_z(object):
- This function sets the z axis to invert.
def go_animation_first_frame(object):
- This function can set to export the scene of the frame after moving to the first frame of the animation. If you call this function, you do not export immediately. This function affects the export function as it progresses through the process function.
- This function can not be used simultaneously with the go_animation_end_frame function, and go_animation_first_frame takes precedence.
def go_animation_end_frame(object):
- This function can be set to export the scene of the frame after moving to the last frame of the animation. If you call this function, you do not export immediately. This function affects the export function as it progresses through the process function.
- This function can not be used simultaneously with the go_animation_first_frame function, and go_animation_first_frame takes precedence.
def set_windcontroller_wind_activate(object, bActivate):
- bActivate is boolean type. default is True.
- This function changes the activation state of the wind controller.
def set_windcontroller_wind_type(object, windType):
- windType is an integer type. If wind type is 0, sphercal. 1, then planar. default is 1.
- This function sets the type of wind.
def set_windcontroller_wind_strength(object, strength):
- strength is floating point type. default is 1000.00
- This function sets the wind strength.
def set_windcontroller_wind_decay(object, decay):
- decay is a floating point type. default is 0.00
- This function sets the distance that the wind effects. The wind weakens along parabolic line by the set value.
def set_windcontroller_wind_frequency(object, frequency):
- frequency is floating point type. default is 0.00
- This function sets the wind cycle. Depend on set value interval in seconds, the winds become weaker and stronger.
def set_windcontroller_wind_turbulence(object, turbulence):
- Turbulence is a floating point type. default is 30.00
- This function sets the irregular degree of wind intensity. The larger the value, the more irregular.
def set_windcontroller_translate_x(object, x):
- x is a floating point type. default is -700.00
- This function sets the x coordinate position of the wind controller.
def set_windcontroller_translate_y(object, y):
- y is a floating point type. default is 1000.00
- This function sets the y coordinate position of the wind controller.
def set_windcontroller_translate_z(object, z):
- z is a floating point type. default is 300.00
- This function sets the z coordinate position of the wind controller.
def set_skin_offset(object, offset):
- offset is floating point type. default is 3.0
- This function sets the distance between the avatar and the garment.
- This function sets the y coordinate position of the wind controller.
def single_process(object, open_garment_path, open_avatar_path, open_animation_path, save_file_path, obj_type = 0, simulation_delay_time = 5000, simulation_quality = 0, simulation = True, auto_save_project_file = True):
- single_process sequentially loads files from path which received from factor and save result to save_file_path.
- obj_type only applied when opened file is obj. if value of obj_type is 0, obj file will be opened as avatar, if it is 1, it is opened as trim object and if it is 2, it will be opened as obj to Garment file.
- simulation_delay_time is used to set a delay time before process animation for stabilization. Opened avatar and garment will simulate with start pose designated time and start animation.
- simulation_delay_time uses micro seconds (1000 == 1 seconds)
- simulation_quality controls precision of Simulation. When the value is 0 it simulate with Normal quality. When it is 1, it simulates with Complete quality. These options of simulation_quality is the same with Simulation quality of CLO. Please refer to CLO manual for details..
- Simulation factor decides whether it starts simulation after loading files. When it is True, it starts Simulation after load all files. Default value is True.
- auto_save_project_file is the option allows to save Project file to save_file_path. Default value is True.
Note. When calling single_process it only saves file once. Please use “process” function to save multiple files.
def process(object, auto_save_zprj_file = True):
- auto_save_zprj_file is Boolean type, if set auto_save_zprj_file as True, it saves additional Zprj file to the folder which saved to save_file_path or save_folder_path.
- process function open designated files and process and record animation, then save it as animation, garment and avatar file. Import / export setting need to be done before call process function. Process function allows to save and load one or multiple files by saved file list and import / export option.
- Each exported result is set with one import / export option.
Please refer to example.py file for details.
Comments
How to use load morph target through python script ?
The example provided is not working.
Function called is the following:
#this function is example for multi process
def run_multi_example_with_obj_exoprt_option(self, object):
# clear console window
object.clear_console()
#initialize mdsa module
object.initialize()
#Set importing options (unit) of string type
object.set_import_scale_unit("mm")
#Set exporting options (unit) of string type
object.set_export_scale_unit("mm")
#Set exporting options (only export option)
object.on_export_garment_with_relative_objects_only()
#Set exporting options (multi object option)
object.on_export_multi_object()
#Set exporting options (weld option)
object.on_export_weld()
#Set exporting options (thick option)
object.on_export_thick()
#Set exporting options (unified UV coordinates option)
# first value : Unified Textures of boolean type
# second value : Texture Size(Width & Height) of integer type
# third value : Fill Texture Seams of integer type
# fourth value : Texture Margin Property
# True(absolute length(mm)) , False(relative uv coordinate (0-1))
# fifth value : Texture Margin Value
object.set_export_unified_uv_texcoordnate(True, 1000, 5, True, 0.01)
#Set exporting options (include inner shape option)
#object.on_export_include_inner_shape()
#Set exporting options (save with texture files(ZIP) option)
#object.on_export_save_with_texture()
#Set exporting options (save with meta data(XML) option)
#object.on_export_save_meta_data()
#Set exporting options (Diffuse Color Combined on Texture option)
object.on_export_diffuse_color_combined()
#Set exporting options (Exclude Ambient Color option)
object.on_export_exclude_ambient_color()
#Set exporting options (Axis Conversion option) of string type
object.set_export_axis_x("Y")
object.set_export_axis_y("Z")
object.set_export_axis_z("X")
#Set exporting options (Axis Invert option)
object.on_export_invert_x()
object.on_export_invert_y()
object.on_export_invert_z()
#In case want to simulate/record one garment and avatar with multiple animation
#set path of one garment file
object.set_garment_file_path("C:\\Users\\Public\\Documents\\MarvelousDesigner\\Assets_ver_5.1.99999\\Garment\\ambient_test.zpac")
#set path of one avatar file
object.set_avatar_file_path("C:\\Users\\Public\\Documents\\MarvelousDesigner\\Assets_ver_5.1.99999\\Avatar\\Avatar\\Female_A\\Female_A_V3.avt")
object.set_animation_file_path("C:\\Users\\Public\\Documents\\MarvelousDesigner\\Assets_ver_5.1.99999\\Avatar\\Pose\\Female_A")
#set save folder and extension (file extension must be supported by Marvelous Designer)
object.set_save_folder_path("C:\\Users\\Public\\Documents\\MarvelousDesigner\\Assets_ver_5.1.99999\\Output", "fbx")
#set auto save option. True is save with Zprj File and Image File.
object.set_auto_save(False)
#call the "process" function (to autosave project file, change factor to ture)
object.process()
All the resources are present and when the function is called you can see that item is loaded but there is no resulting obj.
Here is the console output:
Warning: not found last character /
new File Path
MV1_01_A
MV1_01_AMV1_Dario
MV1_01_AMV1_Dario1.Zpac
Is anyone able to save the textures using this script?
Hi Vineet, can we discuss what you are facing?
I am able to save the obj and fbx files.
I have the same issues as vineet. The save-obj function does not save any .obj files
There has been some issue with the CLO 6.1 python script API. The problem has been resolved in the 6.2 python script API. Apologies for the inconvenience.
Hi everyone!
I'm looking for a way to use options (which are in the CloApiData.h) the ExportGLTF.
I tried several things that doesn't work... What do I need to import in order to use ImportExportOption? How to call it ?
My code works but I want to use options.
Best regards
mdsa - import this or using it is not working. Clo 7.3. Can't use any of the methods above. Initial lines of example.py (I found it on the web) also not importing. In sys.modules , sys.path, globals - nothing specific - seems like pure python and that's all. Should I somehow download python api or what can be the issue?