Python : Script log | tool presets

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  09 September 2015
Python : Script log | tool presets

I don't know a thing about python - I was under the impression that I would be able to set some tool options and then create a button to 'run' them essentially. At the moment I just used the following - Straight from the script log -


import c4d
from c4d import gui

def main():
    c4d.CallCommand(431000015) # Bevel
    tool()[c4d.MDATA_BEVEL_RADIUS]=10
    tool()[c4d.MDATA_BEVEL_SUB]=0
if __name__=='__main__':
    main()



I'm just wanting to create a couple of presets to apply bevels & extrudes on selected edges / faces etc. Any help would be much appreciated.

Console - NameError: global name 'tool' is not defined. << thats one problem along with a few others I'm sure.
 
  09 September 2015
Hi Matt,
I think the best place to get accurate and fast scripting advice is the official Maxon Developer support website:

https://developers.maxon.net
__________________
Follow me on Twitter@nosemangr - Watch me on Noseman's Youtube Channel
 
  09 September 2015
You need to declare tool first:
import c4d

def main():
    c4d.CallCommand(431000015) # Bevel4
    tool=doc.GetAction();
    tool=c4d.plugins.FindPlugin(tool, c4d.PLUGINTYPE_TOOL)
    tool()[c4d.MDATA_BEVEL_RADIUS]=10
    tool()[c4d.MDATA_BEVEL_SUB]=0
    c4d.EventAdd();

if __name__=='__main__':
    main()

Last edited by kgkldfsmm : 09 September 2015 at 04:48 PM.
 
  09 September 2015
You could also give my Tool Presets plugin a try: http://blog.niklasrosenstein.com/2015/04/tool-presets/
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
  09 September 2015
Thanks Sergey- all sorted now- I had another little play around with it and have the python working with some other tools also. I think I'll work through codecademy and cineversity - just for a few small task here and there - awesome

developers.maxon.net/ good to know - thanks

I downloaded the tool preset (can't believe I didn't google it first) it worked for literally five minutes before I updated to the most recent version of R17 - which had a python update. Then it wouldn't work - in the plugin manager it is there with a little python badge and a mini x on it. Maybe its me - but I restarted and still the same issue.

Thanks for the help.
 
  09 September 2015
Thanks for letting me know, I'll check that asap.
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
  09 September 2015
Please re-download the plugin (in version 2.1), it should work with the latest version of R17 now.
__________________
Cinema 4D Plugin Developer
niklasrosenstein.com/ | Freebies | Plugins
 
  3 Weeks Ago
I'm stuck...
I try to get the bevel tool working on a selection of points of a (flat) polygon object. I can change the bevel settings but I can not get the bevel tool "applied" to the points.

The code I am trying now is :

import c4d
from c4d import documents, plugins

def main():
c4d.CallCommand(431000015) # Bevel4
tool = doc.GetAction();
tool = c4d.plugins.FindPlugin(tool, c4d.PLUGINTYPE_TOOL)
tool()[c4d.MDATA_BEVEL_RADIUS]=5
tool()[c4d.MDATA_BEVEL_SUB]=2
tool()[c4d.MDATA_BEVEL_DEPTH]=-1
c4d.EventAdd();

if __name__=='__main__':
main()

What do I need to add to this?
 
  3 Weeks Ago
You'll need to execute the tool's Apply button using code like this:
import c4d
from c4d import documents, plugins

def main():
 c4d.CallCommand(431000015) # Bevel4
 tool = doc.GetAction()
 tool = c4d.plugins.FindPlugin(tool, c4d.PLUGINTYPE_TOOL)
 tool()[c4d.MDATA_BEVEL_RADIUS]=5
 tool()[c4d.MDATA_BEVEL_SUB]=2
 tool()[c4d.MDATA_BEVEL_DEPTH]=-1 
 
 #Executes the Apply button
 c4d.CallButton(tool, c4d.MDATA_APPLY)

 c4d.EventAdd()

if __name__=='__main__':
 main()


-ScottA
__________________
My Gallery
 
  3 Weeks Ago
Thank you for taking the time to look at my c4d problem.

I 'copy-pasted' the code you provided and it works the way I need it.
Still so much to learn. Thanks again Mr Scott
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:51 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.