Search - User list
Full Version: accessing to custom attributes
Root » Houdini Engine for Unity » accessing to custom attributes
chabis
i'm looking for accessing to an HDA custom attributes in unity by script.

for example, my HDA contain a primitive attribute “address”(an integer)

is it possible to know in unity the value of this attribute for a specific primitive of my HDA ?
seelan
Search for `GetAttributeIntData` in the plugin's source code. It ends up calling HAPI_GetAttributeIntData which is documented here: https://www.sidefx.com/docs/hengine/_h_a_p_i_8h.html#addc0eb499a75e7764fcec857cd3e3814 [www.sidefx.com]
chabis
thanks a lot.
chabis
ok,
i've try to understand how to use it. i've read a lot, and understood a part, but after all, it's a fail for me: HAPI_GetAttributeIntData seem to be unknown.

below there's my code: (it's just some try to learn) in the first part, i'm trying to access to a parameter (and it's ok).
in the second part, i'm trying to access to an attribute but the last line is wrong (“HAPI_GetAttributeIntData does not exist in the current context”).
i've try a lot of way to write it, looking for examples, all is a fail …
can someone help me ?


HEU_HoudiniAssetRoot myroot = (HEU_HoudiniAssetRoot)curSelected.GetComponent<HEU_HoudiniAssetRoot>();
HEU_HoudiniAsset myhda = myroot._houdiniAsset;

// get parameters
HEU_ParameterData paramData = myhda.Parameters.GetParameter("princ_etages");
outvalue = paramData._intValues[0];
Debug.Log(outvalue);

// get attributes
HAPI_AttributeInfo attr_info;
attr_info.owner = HAPI_AttributeOwner.HAPI_ATTROWNER_PRIM;
attr_info.storage = HAPI_StorageType.HAPI_STORAGETYPE_INT;
attr_info.count = 0;
attr_info.tupleSize = 1;
HEU_AttributeData testdata = HAPI_GetAttributeIntData.GetAttributeIntData(null,0,0,"adresse", attr_info,0,1,0,1);
seelan
You can't call HAPI_GetAttributeIntData like that. Search in the plugin codebase to see how its being called in other places.
chabis
ok, i've search more (and well) and i've finded how to use it.
thanks you seelan !
chabis
ok, that's a fail again…
i can't find a part where's used in the plugin codebase.
sorry but.. can you show me a short example of how to get the value of an attribut…?

i Don't understand what i Don't understand …
seelan
So you can use a helper to get your int attributes:

HEU_SessionBase session = GetHoudiniSession(true);
HAPI_AttributeInfo addressAttrInfo = new HAPI_AttributeInfo();
int[] addressAttrData = new int[0];
HEU_GeneralUtility.GetAttribute(session, 0, 0, "address", ref addressAttrInfo, ref addressAttrData, session.GetAttributeIntData);
chabis
humm , after un long time, i'm trying to understand again…
i've try to use your example, and read again scripts and documentation..


at this time, i need to access to my asset and make a list of nodes and part, because unity answer that the ID i use is invalid.
i had a look of the examples in the plugin (HEU_ScriptMeshInputUVLayoutExample) but it's seem not to be what i need (or i Don't understand..)

so, my question is: how to know the ID of the node and the part ?

i've try with some default values like 0 or 1 , how that could be “invalid” ?
(in my example, “adress” is an attribute for every prim in my OTL.)

i've try to use HAPI_NodeInfo(),HAPI_GeoInfo() and HAPI_PartInfo() but at each time i need a nodeID.


in my mind, what i want to do (to know the value of an attributes of a prim) seem to be “the base” and i'm very confused.

thanks for your help seelan
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB