Page 1 of 1

Set tokens from python

PostPosted: Wed May 09, 2018 3:40 am
by mois.moshev
As the title said, is it possible to set tokens from python?
If not, consider it a feature request :)

Re: Set tokens from python

PostPosted: Thu May 10, 2018 7:09 am
by jokermartini
Are you trying to set tokens using MaxPlus Python?
Is that what you are trying to do?

More details on what you want to do will be easier to put together a solution or example.

Re: Set tokens from python

PostPosted: Thu May 10, 2018 7:15 am
by mois.moshev
Well, any way that works would be fine. I am using both MaxPlus and pymxs.
So perhaps the right solution would be to define a maxscript set_token function?

I just thought there might be a python api for this already..

Re: Set tokens from python

PostPosted: Fri May 11, 2018 2:52 pm
by boomer
Mois,

You are aware that there is Maxscript Token node, right? Would that work in the meantime?

Re: Set tokens from python

PostPosted: Fri May 11, 2018 2:52 pm
by jokermartini
You can currently do this with the Maxscript Token node. have you tried that at all?
We can skype and go over it if you want.

Re: Set tokens from python

PostPosted: Mon May 14, 2018 1:10 am
by mois.moshev
That's why I am asking about Python, since I know there is a Maxscript Token node.
We could have an online discussion later on - we are still too early in the process, and just jabbing at the program, exploring.

btw we already have a python library that we import and use in Maxscript anyway, so the Maxscript node might be just fine.

Re: Set tokens from python

PostPosted: Mon May 21, 2018 5:01 pm
by boomer
Mois,

Adding a Python Token node is under consideration for a future release.

Re: Set tokens from python

PostPosted: Tue May 22, 2018 6:35 am
by mois.moshev
Cool, thanks!

Re: Set tokens from python

PostPosted: Tue May 22, 2018 8:34 pm
by boomer
Mois,

After further investigation, we have discovered that this is not possible within the MAX SDK. However, we have a work around that should do this trick: Create a Python snippet node as a child node to a MXS Token Node. The Python node would set a MaxScript global and the MXS Token Node would simply return that global value.

Attached is simple sample that sets the name of a render element based on a token created in Python.

Please let me know if this solution works for you.