Identifying nodes by type and assets

I'm trying to identify the nodes in a scene belonging to specific types, e.g. clothing.

The first thing I'm trying is getting the presentation for a DzNode. The DzPresentation::type has values like Follower/Wardrobe/Dress, which is useful. However, not all clothing items seem to have this set correctly. Some I encountered just have Follower, for example, which isn't specific enough.

My next idea is to get the metadata for the node's underlying asset. Each node has an assetID, but I can't figure out how to convert it to a DzAsset, from which I can get the relevant categories. The DzAssetMgr class doesn't seem to provide anything useful in that regard. How can I go from DzNode to DzAsset?

More generally, is this the right approach to classifying nodes? Or is there a better way?

Comments

  • Metadata is made by humans, so it's never going to be completely reliable.

    Could you use the AssetURI to get the asset from AssetMgr?

  • Rob says:

    A node is typically going to come from a support asset, not a user-facing asset, so even if you do get a DzAsset for it, that asset will not have categories.
     

    (function(){        var oNode = Scene.getPrimarySelection();    if( !oNode ){        return;    }        var oAsstMgr = App.getAssetMgr();    if( !oAsstMgr ){        return;    }        var sAssetUri = oAsstMgr.getAssetUriForNode( oNode );        print( "Asset URI:", sAssetUri );    if( sAssetUri.isEmpty() ){        return;    }        var oAssetUri = new DzUri( sAssetUri );    var sFilename = oAssetUri.filePath;    print( "Relative Filename:", sFilename );    if( sFilename.isEmpty() ){        return;    }        var oHandle;    var oAsset;        var aAssets = oAsstMgr.findAssetsForFile( sFilename, false, true );    for( var i = 0, n = aAssets.length; i < n; i += 1 ){        if( typeof DzScriptHandle != "undefined" ){ //>= 4.15.0.6            oHandle = new DzScriptHandle( aAssets[i] );            if( oHandle.valid ){                oAsset = oHandle.handle;            }        } else { //< 4.15.0.6            oAsset = aAssets[i];        }                if( oAsset ){            print( "Categories:", oAsset.categories );        }    }    })();

     

  • tianxiangxiongtianxiangxiong Posts: 21
    edited August 2021

    I'm afraid this doesn't do the trick.

    Take this Aurore product, for example. I have this character in the scene. Attached is an image of the category metadata I'm trying to get (dunno how to insert images inline here).

    > /Default/Figures/People/Female/Real World

    But the asset URI I'm getting is

    >  /data/DAZ%203D/Genesis%203/Female/Genesis3Female.dsf#Genesis3Female

    And the metadata (attached JSON) has no categories at all.

    And that's one of the few nodes for which the asset manager can even find assets for file. Most of them come up empty. I wonder if it has to do with the asset's install directory; the docs say DzAssetMgr::findAssetsForFile takes a relative path which I assume is relative to the default content install dir. Most of my assets are in a different dir that I've added to the Content Directory Manager. I don't see a way to feed that into the asset manager.

    Luckily for me, this particular node does have a presentation type of Actor/Character that I can use to identify as a figure. But take another example, which is the handbag from this product (see other image). The category is 

    > /Default/Accessories/Hands

    But when imported into the scene, the presentation type is

    > Prop/Arm/Right/Hand

    And no assets are found via the URI at all.

    aurore_categories.png
    639 x 306 - 17K
    chwo_bag_categories.png
    638 x 362 - 21K
    json
    json
    aurore_metadata.json
    3K
    Post edited by tianxiangxiong on
  • /Default/Figures/People/Female/Real World is a category, /data/DAZ%203D/Genesis%203/Female/Genesis3Female.dsf#Genesis3Female is a relative file path (starting from a content directory, the whole point of using relative paths is that they work ragardless of the location of the content directory - including the /data/cloud/1_SKU/ folders in a Connect install). The function returns an array to allow for multiple assets (e.g. if the item you asked for is a shared files isntalled by multiple products, and so having multiple locations if installed through Connect)

    Note that you also seem to be confusing categories (e.g. /Default/Accessories/Hands) and content types (Prop/Arm/Right/Hand).

Sign In or Register to comment.