With extensive help from a bunch of you, I've completed my first mini addon! (source code at the bottom).
The Texture Resolution Presets addon. It's pretty trivial, but I had a clear goal of what I wanted it to do and accomplished it. Pretty proud of myself right now. So all it does is creates 3 buttons in the UV/Image Editor's properties panel. When you click a 1k, 2k or 4k button it creates a new image prompt with the correct resolutions already filled in!
So you'll see this in the UV/Image Editor properties (N) panel:
after clicking 4k you see this:
Now just fill in the rest of the name/options and hit OK and a new image gets created for you.
Some preliminary thoughts and questions for you:
1) I wanted the Name field to have an appendix reflecting the resolution, but for some reason the name property wasn't being accepted when I was calling the operator for example (operator_props.name = "Untitled_4k"). No idea why it's not working.
2) I'm wondering how better to make it fit blender's design paradigms and if the location I put it is the best place for it to make it the most useful (the idea was it was supposed to save you typing).
3) I'm wondering if I went the right way about setting up and calling the operators (I found the tips on a website for calling operators with arguments, in my case the width and height)
4) Even though it's a simple addon, it's a mishmash of a few examples, and templates I've seen around and in blender itself. What this means, is that, although the addon works, I don't know 100% why it works. This relates to point #3. I'm not sure what exactly I did there (or more specifically why)
How I got to this point:
1) First and foremost learning from two CGCookie tutorials:
- Course: Introduction to Python Scripting for Blender ArtistsList item
- Creating a Custom Toolbar Panel with Python Scripting
2) Learned basics of python and object oriented programming on TeamTreeHouse based on @jonathanwilliamson 's recommendation. Interestingly enough the courses are so compact, that it only took me about 3 hours in one evening to go through the relevant material. I also highly recommend it. If dollars are tight, you can learn all you need in the 14 day free trial for sure.
3) And believe it or not, even though it is in its infancy, this forum. Thanks @sweenist for dealing with all my questions (as well as all others who chimed on my previous post).
4) Digging through the Blender API website to gain familiarity with some of the layout tools I was using.
So here goes!
Texture Resolution Presets Addon for your consumption.
You can download it here:
Direct Download for the texture_presets.py file from my GoogleDrive
It can be installed like any other addon through "Install from file..." in Properties.
If you're security conscious, just copy and paste the source code from here:
bl_info = \
"name" : "Texture Resolution Presets",
"author" : "Szymon Buhajczuk <email@example.com>",
"version" : (0, 9, 0),
"blender" : (2, 7, 1),
"location" : "Image Editor > View/Edit Mode > Properties Panel",
"Creates buttons that launch the New Image panel with predefined resolutions filled in",
"warning" : "",
"wiki_url" : "",
"tracker_url" : "",
"category" : "UV",
"""Creates a Texture Resolution Preset Panel in the UV/Image Editor Properties Pane window"""
bl_label = "Texture Resolution Presets"
bl_idname = "OBJECT_PT_texturepreset"
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
row = layout.column(align=True)
row.label(text="Standard Texture Resolutions", icon='TEXTURE_DATA')
row = layout.row(align=True)
operator_props = row.operator("image.new",text="1k")
operator_props.width = 1024
operator_props.height = 1024
operator_props = row.operator("image.new",text="2k")
operator_props.width = 2048
operator_props.height = 2048
operator_props = row.operator("image.new",text="4k")
operator_props.width = 4096
operator_props.height = 4096
if __name__ == "__main__":