Remove Product
Anyone knows how we can remove a product correctly using C++?
DzAssetMgr* assetMgr = dzApp->getAssetMgr();
DzTopLevelAssetContainer* products = assetMgr ? assetMgr->getProducts() : nullptr;
if (products)
{
DzAbstractAssetContainerList children;
if (products->getChildContainers(children))
{
for (int i = 0; i < children.count(); ++i)
{
DzAbstractAssetContainer* child = children[i];
if (child && child->getID().toString() == globalID)
{
DzAbstractAssetContainer* parent = child->getOwner();
if (parent)
{
parent->removeChildContainer(child);
}
break;
}
}
}
}

Comments
OK, I figure it out how to remove a product, but how we can refresh smart content?
QString globalID = jsonObj.property("globalID").toString(); if (globalID.isEmpty()) { return; } DzAssetMgr* oAssetMgr = dzApp->getAssetMgr(); if (!oAssetMgr) { return; } DzTopLevelAssetContainer* oProductsTop = oAssetMgr->getProducts(); if (!oProductsTop) { return; } DzAbstractAssetContainerPtr oIntermediate, oProduct; int nIntermediates = oProductsTop->getNumChildContainers(); for (int i = 0; i < nIntermediates; i += 1) { oIntermediate = oProductsTop->getChildContainer(i); if (!oIntermediate) { continue; } int nProducts = oIntermediate->getNumChildContainers(); for (int j = 0; j < nProducts; j += 1) { oProduct = oIntermediate->getChildContainer(j); DzProductAssetContainer* product = qobject_cast(oProduct); if (!product) { continue; } QString guid = product->property("guid").toString(); if (guid == globalID) { oIntermediate->removeChildContainer(product); return; } } }The AI seems to have drawn pretty thoroughly on http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/metadata/list_products/start
what you mean by "AI"? I don't get it?!
Did you even undrstand what is my question? I am talking about how to properly REMOVE a product, so what is point of AI here?
This is offensive to someone who spent several days working on this code to make it workable!
Anyway, now my concern is how to refresh panes properly to reflect that update. if someone can talk about that topic, it helps me a lot.
Sorry, I was getting this confused with another thread by someone who doid use AI to generate a script. But still, you should provide a proper acknowledgement of the source scripts you useas a reference - that is how theya re licensed.
OK, no problem,
This is my style that I send anything I found myself to help everyone here, so we able to inceremantally reach the goal together.
In this case. I used that sample code for sure without even renaming variables. I translated that dazscript code to C++ to retrive the product and delete it. but problem is SDK and dazscript are not exactly the same. using dazscript we can simply do:
But problem is, in C++ version Smart Content and Content Library panes will not be updated, so we should do some more codes to update them.
Despite my intentions I have never engaged with the SDK so I am of little use. In this case you are already doing what I would try, looking for parallels with the scripting engine.