Creating an ‘Add Mesh Primitives’ Panel in the Tool Shelf

Hey guys, lets welcome Patrick Boelens as a new guest instructor here on Blender Cookie. We are super jazzed to have him and what he has to bring to the community. Give me a hello, hug or head nod in the comments below.

In this Blender 2.5 video tutorial we will be going over the basics of how to script in Blender 2.5x using the Python programming language.

We will create a Panel in the Tool Shelf with buttons in it that will add Mesh Primitives (Plane, Cube, etc.) to the Scene. We will also take a quick look at adding a name field in the same Panel.

Leave Comment

Discussion

82 Responses to “Creating an ‘Add Mesh Primitives’ Panel in the Tool Shelf”
  1. Posts: 264

    I had to add this line to the end of mine to get the panel to show up:

    bpy.utils.register_class(myTools)

    I update through svn so I am using 2.56.2 r35205. That may have been something that changed in the API after the tutorial was made. I was scratching my head trying to figure out why it wasn’t working, so hopefully that helps people out that are trying to follow the tutorial.

    You have to put the name of the class as the argument. It is myTools because I am modifying the tutorial to make a panel of my most used tools.

    As a quick aside: I noticed their are script templates you can load in the text menu for others that are playing around with python from this tutorial trying to learn.

    Thanks again! It would have taken me ages just to get a panel to show up in the first place!

    • Posts: 225

      Sorry I missed your comment there; wish I’d seen it sooner (I too spend quite a bit of time to figure out what changed). The tip video covering this should go live later today I think. =)

  2. Posts: 1
    247wkman says:

    had an example file with a script called CGLholiday- it was for 2d sprites following the camera, but of course it is glitchy now. its says modual GameLogic does not exist. if the convention refering to moduals has change also let us know if you know.

  3. Posts: 90
    Ben Amend says:

    .

    Young man, it was past your bedtime when you recorded this! ;)

    Nice tutorial!

  4. Posts: 1
    rok cancer says:

    if you’re using blender 2.6 you must add
    bpy.utils.register_class(addObjectPrimitives) after the class body in order for it to work.

  5. Posts: 20

    Thank you so much for this video. I helped me a lot, but I have one problem:
    I wanted to take it one step further and made a separate button for the face rig. It works so that I can hide the face controll bones, thanks to your video, but I have a plane with the rendered photo of the face and there are the face controllers. I spent the whole day yesterday to figure it out, but I’m new to python.. So is there a command or an operator that allows me to hide just one specific object, that isn’t the active object.(I am in the posemode and want to hide a plane). I also need to implement this as a button in the panel I have and I should be switchable like you did with the bone layers.
    http://www.pasteall.org/pic/74913
    Thanks

Leave a Comment

You must be logged in to post a comment.