Similar as for model versioning you just have to get the version id from the thread → those are then the actual instances. Thus, you need one additional line:
1
2CC "Core" debug GET_ALL_ATTRPROF_SUBDIRS
3CC "Core" debug GET_ALL_ATTRPROF_THREADS_IN_DIR apdirid:(VAL token(apdirids,0," "))
4SET nApThreadIDs:(apthreadids)
5
6CC "Core" debug GET_ALL_ATTRPROF_VERSIONS_OF_THREAD apthreadid:(VAL token(nApThreadIDs,0," "))
7SETL nApVersionIDs:(VAL apversionids)
8
9#This is a bit short-handed, assumes only one thread returned.
10CC "Core" debug GET_ATTRPROF_CLASS_OF_THREAD apthreadid:(VAL nApThreadIDs)
11CC "Core" debug GET_ALL_ATTRS classid:(apclassid)
12CC "Core" debug GET_CLASS_NAME classid:(apclassid)
13
14CC "Core" debug GET_ATTR_VAL objid:(nApVersionIDs) attrid:(VAL attrids)
Alternatively, you can use the AQL queries, instead of working with directories, to handle the instances directly.