Posts

Showing posts from March, 2012

Back to MEL

I've used 3dsMax for years, and one of my favorite plugins for it was the good old pitsNpeaks . Using it you could bake in really nice dirt passes into a mesh's vertex color quickly and painlessly. I'm now on the hunt for an equivalent script for Maya, just because it's so very handy.

Styling it up...

Now that I've gotten to grips with making Python scripts that work, I'm paying more attention to readability and style. I've had the PEP 8 Style guide for Python Code recommended to me as a good standard to follow.

TextureMonkey v1.0

Well, here is TextureMonkey V1.0 with the Alienbrain integration. If anybody ends up using it I'd like to hear about how it goes. Also, I'm interested in hearing about the way you integrate it into Photoshop. I integrated it using a javascipt and a call from a batch file, but I'm sure there is a more streamlined way of doing it. In order to get it set up, make sure you fill in the variables up top with your project specifics. These are all called throughout the script to keep it tidy. And here it is: ############################################################################## # # Photoshop texture exporter v1.0 # (C) Pete Hanshaw, 2012 # http://peterhanshawart.blogspot.com.au/ # Inspired by recursive Photoshop layer export script by # Adam Pletcher # http://techarttiki.blogspot.com.au/ # ############################################################################## # # Checks to see if a PSD file is open. # For the currently active file, exports various 24-bit TGA texture...

Python command line text color

Want an error message with a difference? Color Module is an excellent reference if you want to get your command line popping out in any number of different colors. Windows only.

TextureMonkey and Alienbrain

Well that wasn't so hard... using the same win32com interface as the one I am using in to control PhotoShop, I have been able to check out files from Alienbrain within the TextureMonkey script with minimum fuss. Having access to Ben Deda's Alienbrain python interface was a massive help in this! I suggest anyone trying to drive AlienBrain with python to have a good look through it. The script is now pretty self sufficient. It allows a user to export all their maps from a Photoshop document to specified folders It names the exported textures appropriately, based on the document and layer names  It is smart enough to know when to export a texture with an Alpha  channel It can check file permissions and attempt to check out files if required If the files are checked out by another user, AlienBrain shows a dialogue of who has it checked out If it can't obtain file write permissions it closes down and informs the user.    Two issues with the I would like to resolve to mak...

TextureMonkey- next steps

So I have got the script into a working form. It's still got some ugly bits, but it does the job its intended to do well enough to be popular with the other artists and is already showing a lot of promise. So what next?  Currently the script has no idea how to handle exceptions properly, so that's totally on the todo list. The script doesn't like it when the files are not writable, and isn't smart enough at the moment to know what to do about it.  I'm still convinced that I can copy the output TGA's to at least one of the output directories. Although I'm not sure how much time this will save, I'd still like to give it a try. The script execution is pretty rapid, so the savings would only really become apparent on Photoshop files that are spitting out a lot of different maps. So my goals over the next couple of weeks are: Implement effective exception handling Somehow integrate the script with Alienbrain asset management to at least check-out the files if...

TextureMonkey in the pipeline...

While testing out the textureMonkey script I came across a couple of little hurdles to get it working within the current pipeline. The most annoying bug came from the naming of the PSD files themselves. Many had been named with the _d, _n and _s already in the PSD name, in order to work with a Photoshop action that was already doing a basic version of what TextureMonkey was intended for- saving the flattened PSD as a TGA in a couple of different directories. When TextureMonkey was used on these files, it came out with an ugly export name, eg: 'psd_name_d_d' 'psd_name_d_n' 'psd_name_d_s' Lameness, but a reasonably easy fix. I added a basic function that checks for the extensions in the PSD name, and if they were there, to remove them from the export file name: def name_check(name_check): """Checks the PSD name for the old naming convention. """ doc_name = name_check old_name = ('_d', '_n', '_s'...

Running the automation from Photoshop

So, there is probably a better way of doing it, but I have been able to run the script from within photoshop using a javascript that calls a .bat file that then calls my python script. It's a convoluted way of doing it, but it does allow me to directly call textureMonkey using an action from within photoshop. The javascript looks like: var textureMonkey = new File("/z/Tools/textureMonkey/textureMonkey.bat"); textureMonkey.execute(); and the .bat file called looks like... @echo off call python Z:\Tools\textureMonkey\textureMonkey.pyw The whole thing has been very easy to set up for the art team and is already saving time that would have otherwise been spent navigating folders and changing file names. -Pete

More scripting reference

In addition to the adobe com reference and VB scripting reference , I've been taking a look through another site called tranberry to learn more about photoshop scripting. I'll post if anything handy comes up.

Photoshop Automated Texture Exporting

Python Texture Monkey Requires the Win32 Extensions: http://python.net/crew/mhammond/win32/ So the script has progressed far enough to be usable, but still has several crude elements, such as the way it exports the TGAs into each separate folder.   Currently the script works like so:  Using python grabs whatever doc is currently active in Photoshop and looks through it for specified group names Exports each of these groups as a TGA in specified directories with a specific suffix depending on the original group name- eg the diffuse 'd' group becomes 'sourceTextureName_d' Saves original doc and reverts control to user Can export: 'd' - Diffuse as 'fileName_d.tga' 'n' - Normal as 'fileName_n.tga' 's' - Spec as 'fileName_s.tga' 'i' - Illuminance as 'fileName_s.tga' 'a' - Texture with alpha as 'fileName_a.tga' 'g' - Gloss as 'fileName_g.tga' This script is based on a recursive lay...

The Code... or is it?

So I got it working, but now I need to find a decent way of displaying code on my blog! Stay tuned!

Automated Texture Exports

I've got far enough in Python to start taking apart other people's scripts and reassembling them to do the things I want them to do. Towards this end I have taken the Photoshop layer exporter script by Adam Pletcher and modified it in several key ways to adapt it to the pipeline I'm currently working in. I found the adobe com reference of moderate help, as well as the VB scripting reference , especially when I needed to search for specific things like how to step back to a previous history state.  The key differences between my script and Adam's are: My new script exports TGA files rather than PNGs  The script runs on the currently active Photoshop doc rather than recursively scanning through a folder. This is handy as it can be integrated directly into a user's workflow for rapidly updating work.  Due to my current test project setup, TGA files are exported to two different folders- a Maya 'asset' location and an engine 'export' location.  The sou...