Assign category to file
![rannar22](https://secure.gravatar.com/avatar/05e7be4d12a7d137c4130a15740bd7d4?&r=pg&s=100&d=https%3A%2F%2Fvanillicon.com%2F05e7be4d12a7d137c4130a15740bd7d4_100.png)
I am trying to assign a set category to a spesifc file using a script.
unfortenetly so far i have only figured out how to read the categoris.
Post edited by rannar22 on
You currently have no notifications.
I am trying to assign a set category to a spesifc file using a script.
unfortenetly so far i have only figured out how to read the categoris.
Licensing Agreement | Terms of Service | Privacy Policy | EULA
© 2025 Daz Productions Inc. All Rights Reserved.
Comments
I assume you are aware of this sample, since you say you have managed to read categories. In any event, the DzAsset object http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/asset_dz has an addToCategories() method which shoudl be what you are looking for.
unforteently this is where i get stuck
aAssets = oAssetMgr.findAssetsForFile(relPath, true, true);
if(aAssets.length== 0){
//i know i need to add addToCategories here
//aAssets.addToCategories(catName);
}
aAssets is an array, so you need a loop to go through the array one asset at a time (if you start you loop at 0 and check that the current value is less than aAssets.length then it will not need the if you have as it will just loop 0 times). You then, for each one, use an array of categories to add that asset to one or more categories -
for example.
i am sorry i wasn't clear before.
I am trying to add a category to a specific file (based on relative path)
that file has no assets at all, so obviously the aAssets[ 0 ] will not be defined when i try to use it.
You cannot categorise soemthing that is not an asset in the database - there'd be nothing to hang the category on. First you need to set the item as an asset, then you can categorise.
ok, and how can i do that?