Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

How to check data type?

g2m.agent
Collaborator

How to check data type?

g2m.agent
Collaborator
Collaborator

something like this python code:

 

 

if type(var) is list:
    # do list thing
elif type(var) is int:
    # do int thing
elif type(var) is float:
    # do float thing
...

 

 

 

 
0 Likes
Reply
Accepted solutions (1)
713 Views
6 Replies
Replies (6)

Christoph_Schaedl
Mentor
Mentor

Does this tool what you are looking for?

https://www.youtube.com/watch?v=ISaGk_V6dAg

----------------------------------------------------------------
https://linktr.ee/cg_oglu
0 Likes

g2m.agent
Collaborator
Collaborator
no. I want to check the data type inside my custom compound.

and that tool does not work in 2022.
0 Likes

mjcg91
Collaborator
Collaborator

You can't test data types directly like this. if the data is stored as a property or geo_property, then you can test it by checking if the property's data is valid or not when trying to get it.

You could use multiple geo_geo_property_check nodes, all using the same property but each one with the data types you want to test. the found_property port will only return true if both the property and type are valid. For simpler data you could make get_property editable and expose the success port. 

Maxime Jeanmougin - Technical Artist
https://maximejeanmougin.com

Join the Bifrost Addicts community on Discord:
https://discord.gg/bifrost-addicts

g2m.agent
Collaborator
Collaborator

Basically, I want to make a compound to check the array. like this:

maya_qliey6vAmV.png
But it only targets array<float3>.

I have another compound specifically for array<int> and array<float>.

maya_yVf0A43lnq.png

Their processing process is basically the same (numbers_to_string, then string_join), so I wonder if I can combine the two compounds into one, and change it slightly depends on the input data type. but it doesn't seem to work.

0 Likes

mjcg91
Collaborator
Collaborator
Accepted solution

If you plan on publishing the compound, then I recommend you make a compound with overloadable port. Basically, depending the input data type of a port, the content of the compound will change.

So you could just make the compound called something like "print_array", have an "array" input, "string_output". You publish the compound a first time with the default data type you want (like float for example), and then you can change the input data type and the content of the compound. After this, re-publish it with overloadable enable, and once you import the compound, it will accept all the data types you've used to publish, and the content will change automatically.

Maxime Jeanmougin - Technical Artist
https://maximejeanmougin.com

Join the Bifrost Addicts community on Discord:
https://discord.gg/bifrost-addicts
0 Likes

g2m.agent
Collaborator
Collaborator

I tried it, but not successful.
I think I'd better wait for the next upgrade of Bifrost. I hope there is a better way.

0 Likes