To place a clip asset with code the following lines can be used.
let myAsset = project.project.getAssetByName(MY_ASSET_NAME);
project.project.createClipInstanceFromAsset(myAsset, MY_ASSET_X, MY_ASSET_Y, (clip)=>{});
The first line will retrieve the asset from the project. Replace the MY_ASSET_NAME with the name of the asset as a string.
For example:
let myAsset = project.project.getAssetByName("myClip.wickobj");
The second line then places the clip in the variable named myAsset
from the first line at a position with a x value of MY_ASSET_X
and with a y value of MY_ASSET_Y
.
For example:
project.project.createClipInstanceFromAsset(myAsset, 360, 240, (clip)=>{});
The final bit in the second line of (clip)=>{}
is a function that will run once the clip has been placed with the parameter of clip
that is the clip placed. This is useful if you what to do something immediately to the clip or to save it to a variable to be used later.
For example to place out a clip asset with a name of myClip.wickobj
at position [360,240] with
a rotation of 25:
let myAsset = project.project.getAssetByName("myClip.wickobj");
project.project.createClipInstanceFromAsset(myAsset, 360, 240, (clip)=>{
clip.rotation = 25;
});