In this tutorial, we will write a script that executes the process from creating a project to registering a Waveform to a Cue.
Below is the basic method to create an object:
Select "Script list..." in the Script menu to display the Script list window.
Click the New button in the Script list window to create a Script file with the name below:
Save location of Script | Script file name |
---|---|
tutorials [CRI] | tutorial02-1_new_basic_project.py |
Double-click the created Script to open by Run the Script from the Script Editor .
In order to get an overview of the Script in the Script list window, write the Script description as follows:
Once you have written the Script description, import the following modules to work with CRI Atom Craft in your Script. Write the Script in Run the Script from the Script Editor to import:
Other than Python's standard module "sys" and "os", this time we will import two modules to work with CRI Atom Craft.
In addition to the Debug Module used in the Display "Hello, World" in the Script log tutorial, the Project Module is imported to work with the project data of CRI Atom Craft.
Write a Script including the project name to create, the project save destination, and the location of the Waveform file for the tutorial:
Item | Details |
---|---|
Project name | TutorialProject_Robot |
Save destination of the project | PC's "Documents/CRIWARE/CriAtomCraft/projects" |
Location of the Waveform file for the tutorial | Tutorial folder's "tutorials/robot/local/tutorial_data" |
Write a Script of these project information as follows.
The "os.path.expanduser" function in Python is an "os" module function that expands "~" to user's home directory in a created path.
"~" will be replaced in the above directory.
The "os.path.isdir" function is used to check whether the path is an existing directory. If not, use the "os.makedirs" function to create a directory.
The "os.path.dirname" function is used to get the directory path.
In Python, " __file__ " is used to get the current file path.
The Waveform file used in the tutorial is located in the "tutorial_data" folder above the running Script file.
Execute os.path.dirname twice to get the above directory and specify the 'tutorial_data' to the location of the Waveform file for tutorial use.
We have introduced how to set the import settings of the module to be used, the project name, and the project save destination.
Apply to work with CRI Atom Craft data in the following.
In the Project Module by the importing module, you can use the following function to create a project and Work Unit.
Function name | Description |
---|---|
create_project | Creates a project |
create_workunit | Creates a Work Unit |
Write a Script to use these functions to create project and Work Unit as follows:
Write and execute the Script.
When the Script is executed, it will create the "TutorialProject_Robot" project including Work Unit "WorkUnit_Tutorial" under "Documents/CRIWARE/CriAtomCraft/projects".
Specify "Project name", "Project save destination" and "Whether to overwrite the project" in the create_project function that creates projects.
If you specified "Whether to overwrite the project" as True , even if a project with the same name exists in the project save destination, it will overwrite and create a new project.
When executing the function, it will return as a return value.
And store the value in the "result" variable.
In the "result" variable, various information of the executed result is stored and you can use the identification character(key) to retrieve the information.
Use the "succeed" key to get whether the executed function is succeeded.
Get the information result of the "succeed" key that is stored in the "result" variable, and confirm whether creating project is succeed.
If it fails to create project, it will output the log and terminates the Script execution.
Specify the information of "Work Unit name", "Whether to manage Material in Work Unit" and "Bus Map to set when creating Cue" in the create_workunit function that creates Work Unit.
When executing the create_workunit function, the return value will be stored in the "result" variable like the create_project function.
Information of the "succeed" key is stored in the "result" variable while information that identifies the created Work Unit is stored in the "data" key.
In order to get the information of the Work Unit after determining whether creating Work Unit has succeeded, get the Work Unit information in the "result["data"]" to store in the "workunit" variable.
This section has introduced how to create the project and Work Unit.
Register the Waveform file to the Material information of the created Work Unit, and create a Material.
Use the following function to register the Waveform file in the Material root folder.
Function name | Description |
---|---|
get_material_rootfolder | Gets a Work Unit's Material root folder |
register_material | Registers a Waveform file to create Material |
Write a Script to use these functions to register the Materials as follows:
Specify "Folder of the register destination" and "Waveform file to register" in the register_material function to register Material.
First, use the get_material_rootfolder function to get the Material root folder of the Work Unit.
Next, use the register_material function to register the Waveform file in the Material root folder and create a Material.
By running the Script, you can check that the "gun1_High.wav" Material has been created in the Material root folder of the Work Unit.
This tutorial introduced how to register the Waveform file in the Material information of the Work Unit.
Use the following function to create a Cue Sheet and a Cue under it, register the Material in the Cue to create the Waveform region.
Function name | Item |
---|---|
get_cuesheet_rootfolder | Gets the Cue Sheet root folder of Work Unit |
get_child_object | Gets the child object by specifying the parent object |
create_object | Creates object by specifying type |
create_waveform_region | Creates the Waveform region |
Write a Script to use these functions to create Cue Sheet and Cue and Material settings as follows:
Use the get_cuesheet_rootfolder function to get the folder of the destination of creating Cue Sheet, and get the Cue Sheet root folder of the Work Unit。
Next, use the get_child_object function to get the "WorkUnit_Tutorial" folder directly under the Cue Sheet root folder.
Specify the "Object information of the obtained source", "Object type to get" and "Object name to get" in the get_child_object function.
The WorkUnit_Tutorial folder is a folder with the same name as the Work Unit, which is automatically created when creating Work Unit.
By creating a Cue Sheet in this folder, the output destination of ACB(game data)can be separated for each Work Unit.
Specify the Cue Sheet folder of the above created destination, Cue Sheet object type "CueSheet" and the Cue Sheet name "Tutorial" to create a Cue Sheet in the create_object function, which is a general-purpose object creation function.
Specify the "Object information of the created source", "Object type to create" and "Object name to create" in the create_object function.
Create Cue, Track and then Waveform region in the created Cue Sheet.
Refer to the object structure described in Object structure of CRI Atom Craft if you want to understand why Cue and Track are needed before creating waveform region.
Cue, Track and Waveform region are hierarchically related.
Use the same create_object function for creating Cue Sheet to create Cue and Track.
Waveform region is created by specifying "Track information of the created destination" and "Material to reference" in the dedicated create_waveform_region function.
This tutorial introduced how to create a project and create Cue with a registered Waveform file.
At the end of this tutorial, below will show how to save the created the project.
Use the following function to save the project.
Function name | Item |
---|---|
save_project_all | Saves the project |
Write a Script to use these functions to save the project as follows: