How can I delete an asset from a product?
3D Modeler
Posts: 4
I'm trying to delete an asset from a product. I tried the code below but product.removeAsset("Product name")); always returns false and the asset doesn't get deleted.
var products = oAssetMgr.findProductsByName( "My Product"); var product = products[0]; var assets = product.getAssets(); for(var i = 0; i < assets.length; i++) { if(assets[i].assetName == "Product name") { var removed = product.removeAsset("Product name")); print("Removed asset = " + removed); } }
Comments
You are giving the removeAsset member a name, it needs the actual asset reference - if I am reading your copde correctly something like
see
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/abstractassetcontainer_dz , in particular http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/abstractassetcontainer_dz#a_1a6d39dda53c2eb6314cbd9f1f03207ad2Thanks again, Richard. Yeah, I don't know why I was passing the product name as a string instead of asset.