In this Blender 2.5 video tutorial we’ll be writing a script that creates a custom menu to which we can add operators, enums and sub-menus, as well as taking a look at registering a hotkey for it through Python.
User Submitted Images
No images submitted yet
Discussion
29 Responses to “Scripting a Custom Tool Menu”Leave a Comment
You must be logged in to post a comment.











This was up on the citzen site as early as Thursday so I’ve already had a chance to watch it. It inspired me to much around in the python console and explore the api a little hands on. I found out the other day that you can use python with Gimp as well so I have even more reason to get more proficient with it. Thanks again for taking the time to make these!
As early as thursday?!
lol
Great to see the continuation of more Python scripting tutorials.
I’m now an official Patrick Boelens fan! lol
My mistake. It was Friday. I know I watched it before the weekend. Here is my proof.
http://www.picpaste.com/Screenshot-39dl0CsQ.png
The second part to the sci fi panel is on there as well. I have no reason to lie. Guess it pays to be a citzen.
second part is out!!!!!! i want it now!!!! lol
Awesome Patrick. These are great.
I think I might put this to use to put the special, and 3 context menus into one.
Seems like they should all be under one key lol.
I’m getting the menu header, but not the menu. It displays just “Custom Menu” and nothing else.
Hey BM,
If you’re not seeing anything, but not getting any errors either you probably made a small typo somewhere. If you’re still stuck please feel free to upload your script to pastebin.com or pasteall.org and post the link here so I can take a look at it.
Patrick. Any recommendations for good beginning python books?
@Svcam04
http://openbookproject.net/thinkcs/python/english3e/
Great book, and best of all it’s free.
I just wish I had more time to study and practice.
@ johnathan Hauck. Thank you very much!
Hey, just a random question:
why do you guys use Vimeo and not youtube?
just asking ^^
Vimeo tends to have much better video quality and allows us to designate which domains the video can be embedded on.
-Jonathan
Nice tutorial,
Now menu ID’s are displayed as python tooltips, committed revision 38723.
Also added 2 menu templates.
Ah, awesome! Thanks for the heads-up! =)
Rather than write:
km.keymap_items.new('wm.call_menu', 'O', 'PRESS', False, True, False, True)
You can write:
km.keymap_items.new('wm.call_menu', 'O', 'PRESS', shift=True, alt=True)
Python allows you to specify only the arguments which values you want to change, and leave out the ones you want to leave with their default values. It’s clearer that way.
Oh, nice tip there, thanks!!
Couldn’t you save the script as a .py file and install it as an addon to Blender?
In one of the other python tutorials on here he shows how to register your script as an add on. I forget which one he does it in though.
Thanks for another helpful scripting tutorial. ^^
Hey Patrick. Really liking the Python tuts. Here’s an idea for one, since you were looking, modifying a node or created your own node. Maybe that’s going to deep eh?
Hello!
Thanks for nice coding tutorials!
Out of curiosity – after checking object mesh data export/import one, realised that there should be mirriads of floating point math operations going on under the hood of Blender (surprise…) – does python there make use of cdecimal lib (http://www.bytereef.org/mpdecimal/index.html)?
Couldn’t find answer to this and no – i’m not anyhow related… They talk 12 times speedup tho.
Hey Eppo,
Nice find! But no, this seems to be an optional module, as the site says “cdecimal is a fast drop-in replacement for the decimal module in Python’s standard library”. =)
Patrick, is there any way to have the scrip wait until a “go” button is pressed before running the script?
My script seems to run every time I change a value in my too parameters.
Thanks
That should have been TOOL parameters. Every time I change a setting that updates the classes parameter, the class runs.
Someone pointed me to this e-book too. It contains the steps to create an addon that can be attached to any menu.
And how to find all of the menu object names.
http://airplanes3d.net/pydev-000_e.xml
Can’t get this script to do anything, double checked for typos. Is there somewhere to download this script or cut ‘n paste it? It doesn’t error, it just does nothing.
Hey David
Thank You For Tutorial… And i have one problem by “Run Script”.I don’t know this error.Can You Help Me?
http://d1202.hizliresim.com/u/3/2d5sk.png (Error)
you forgot the : at the end of line 7 mate!