How do I get the Content Type for a DzNode?

I've been looking at the SDK and the script examples.  Some of the functions used in the script examples don't seem to exist in the SDK and some of the functions in the SDK don't seem to do what I think they do.  How do I get the Content Type shown in the Node pane in Daz Studio from the SDK (for instance "Follower/Hair"?  I've got the absolute and relative path to the asset for the DzNode, but can't find a way to convert it.  All the functions that work on the path or the node seem to return and empty string.  I'm going to paste some code in to give some examples of things I've been trying.  I know the values are stomping each other, I've just been trying different things.  I always get an empty string for type.  Thanks in advance.

QString Type = dzApp->getAssetMgr()->getTypeForNode(Node);

QString assetURIString = dzApp->getAssetMgr()->getAssetUriForNode(Node);

DzUri assetURI = DzUri(assetURIString);

QString assetPath = assetURI.toLocalFilename();

QString sRelPath = dzApp->getContentMgr()->getRelativePath(assetPath, true);

//dzApp->getAssetMgr()->find

DzAssetMgr::getTypeForContentFile(sRelPath, Type);

//Type = dzApp->getAssetMgr()->getTypeForContentFile(sRelPath);

 

Comments

  • rbtwhizrbtwhiz Posts: 2,178
    edited November 2018

    You'll want to make sure you're dealing with the correct node.

    DzNode* node = dzScene->getPrimarySelection();if ( DzBone* bone = qobject_cast<DzBone*>(node) ){	node = bone->getSkeleton();}if ( node ){	DzAssetMgr* assetMgr = dzApp->getAssetMgr();	const QString contentType = assetMgr->getTypeForNode( node );}

    Internally, the call above first looks for type on the presentation of the node.

    DzPresentation* presentation = node->getPresentation();const QString presentationType = presentation->getType();

    If the presentation doesn't define a type, an attempt is made to find the content type (in the database) using the path of the content file specified in a data item on the node.

    DzElementData* elemData = node->findDataItem( DZ_SOURCE_FILE_DATA_NAME );if ( DzSourceFileData* sourceData = qobject_cast<DzSourceFileData*>( elemData ) ){	const QString sourceFilePath = sourceData->getSourceFilePath();	if ( !sourceFilePath.isEmpty() )	{		QString sourceFileType;		assetMgr->getTypeForContentFile( sourceFilePath, sourceFileType );	}}

    If the content type isn't defined for the source file, or the data item is missing/empty, an attempt is made to find the content type (in the database) using the content file path of the node.

    const QString nodeFilePath = DzContentMgr::getContentPath( node );if ( !nodeFilePath.isEmpty() ){	const QString nodeFileType = assetMgr->getTypeForContentFile( nodeFilePath );}

    If the CMS is not running, or metadata for the assets does not exist in the database for some reason, the last two attempts will yeild empty strings.

    -Rob

    Post edited by rbtwhiz on
  • Thank you for all the extra info, that helped a lot.  I've got it working now.  It turns out I didn't need to get the skeleton node in my case.  For some reason

    QString type = dzApp->getAssetMgr()->getTypeForNode(node);

    is always giving me an emptry string, but getting the type from the presentation is working for me.

    DzPresentation* presentation = node->getPresentation();if (presentation){	const QString presentationType = presentation->getType();}

    The same was true even when grabbing the skeleton node.

Sign In or Register to comment.