script syntax help
-
On 02/05/2017 at 06:16, xxxxxxxx wrote:
Hi guys,
sometimes I use the Script log to see what a command syntax looks like, and usually fail to create a Python script out of it.
For example, using:
prefs(465001620)[c4d.PREF_INTERFACE_CENTEROBJECT]=True
prefs(465001620)[c4d.PREF_INTERFACE_CENTEROBJECT]=Falseturns the "Create New object at View Center" on and off.
How would I create a script that toggles between states, with the icon being Active (blue) when it's on and grey when it's off?just pasting the code in a script gives me an error:
Traceback (most recent call last) :
File "'scriptmanager'", line 11, in <module>
File "'scriptmanager'", line 7, in main
NameError: global name 'prefs' is not definedCheers
Noseman -
On 02/05/2017 at 07:00, xxxxxxxx wrote:
import c4d def main() : interface = c4d.plugins.FindPlugin(465001620, c4d.PLUGINTYPE_PREFS) interface[c4d.PREF_INTERFACE_CENTEROBJECT] = not bool(interface[c4d.PREF_INTERFACE_CENTEROBJECT]) #toogle c4d.EventAdd() if __name__=='__main__': main()
For the state take a look at my video here (in french)
.
Or look at this post where you have everything you need for doing it https://developers.maxon.net/forum/topic/423/13564_plugins-in-plugin-or-icons&PID=53811#53811Btw I wanted to say a big thank you!
You are one of the guy who inspire me about doing pythonic stuff. So thanks for your love of c4d and all your share ! -
On 02/05/2017 at 10:09, xxxxxxxx wrote:
Thank you so much for your help.
I was trying to help out a user on CG Society.
I'm going to post your script alongside another solution.Also, I'm glad I could inspire you to push the limits of C4D... keep up the great work!
Cheers