Topics by tag:
Recently published articles by Dave G:
The OS X Mavericks upgrade has been pretty painless for me but one thing that seems to be an issue is that QuickLook likes to lock onto files so they think they are open. It’s trivially easy to get the “File in use” error when trying to empty the trash now. Until Apple fixes it, you can try the Secure Empty Trash, but that will be slower since it does multiple passes to write zeros over the space on the disk where the file data was before. This is potentially more of a problem also, if you don’t have backups since a disk data recovery tool won’t find these files. So I made an Automator version of the two-line shell script I use to empty the trash in these cases:
rm -rf /Volumes/*/.Trashes
rm -rf ~/.Trash
That actually deletes the trash folder but the OS recreates one with proper permissions anyway. The Automator workflow can be downloaded here: Actually_Empty_Trash.zip
See it in action:
Use the Shortcuts panel of the Keyboard system preferences to add a hotkey to the service and you’re set:
The script is not dangerous and there is no way it will ever delete anything not in the Trashes folder but, nevertheless, it comes with no guarantees.
If you use a text editor like TextMate, BBEdit or even Chrome in OS X, you get full support for Automator’s text replacement features but some applications don’t use the Cocoa classes for their text boxes so they don’t get access to these. Nevertheless, there is a good workaround for these cases when you want to filter text in one of these Automator-unaware applications: send the clipboard to your Automator script and send the output back to the clipboard. As I mentioned in my recent Ars Technica article, OS X has a ton of command line applications to bridge the GUI and cl (open, say, etc) and they have two built-ins for clipboard manipulation – “pbcopy” and “pbpaste” – which can be used to send text to the clipboard (pbcopy) or echo the clipboard into stdout (pbpaste). So, if I want to take some attribute text from the Maya Script Editor and turn it into a variable, it’s easily done by using this clipboard buffer setup in an Automator service:
See it in action:
That service can be bound to a hotkey in the Keyboard panel of the System Preferences for extra speediness.
If you want to run another instance of any program on OS X, you have to do it from the terminal with the “open -n” command. I have an alias in .bashrc that will do this for Maya 2014:
alias 2014=’open -n /Applications/Autodesk/maya2014/Maya.app’
So, when I type “2014” in the terminal, it opens another instance if Maya is already running. But, since I tend to run both older versions on occasion alongside betas, I thought I’d make something a little more flexible with an input launch whatever version. So I made an Automator service to launch another instance with a prompt for the version you want to launch:
Download the Automator Service here. If you want to change the default version in the text input field, just open it in Automator and change it yourself. Future proof.
I am just moving my work to a new Lacie 2big Thunderbolt enclosure and wanted to save myself annoying task of migrating all my existing work to link to the new disk in place of my old one. There are nice utilities like FileTextureManager for Maya and Nuke has a find/replace that do this on a per-scene basis but this seemed slow since I would be doing the exact same replacement for all future files.
So I made an Automator workflow that reads plain text files and substitutes my “dullard/WORK_mbp” path in the file with “lackey/WORK” and then creates a new file next to the old one so nothing is clobbered. Since Maya ASCII and Nuke files are plain text, the script can use the Unix utils awk and sed as if it were just working on a big (and quite boring) essay.
See it in action:
Grab the Automator workflow here. Obviously, you’ll need to edit the workflow in Automator to substitute your paths instead of mine:
The text between the % are the find and replace terms. The script doesn’t overwrite any files but just for the sake of legalese, it comes with no guarantees.
So, I have this shell script “hammeroutimages” that sends an image to Nuke for batch processing with all my .cube LUTs for a quick image treatment gallery and I have been wanting to make it an Automator action. But then I thought “I have all these one-off shell things that I do on files—why not just make the command itself a variable with input?” So I found out how to do that with a combination of existing Automator know-how with this handy tip, which shows how to pass multiple variables to an Automator workflow for use in a shell script. And I made this bad boy:
What does it do? Anything you throw at it, actually:
If you want an explanation of how it works, read the linked post above. Basically, it takes your text input and assigns it to variable $1 (this is the command) and variable $2 is your file so it sends those to echo and makes a shell script that the Terminal then opens it in Terminal.app. I could have it do it sans file but I like to see the output for some commands in a window.
Open the Automator file and change the default command to something you do often and you’ll also probably want to change the script file path to something other than your desktop.
You could probably edit the Automator workflow to use selected text as an input so that you could use something like awk in your text or HTML editor. That might get a little hairy with encapsulation of stuff though, so I’m not positive how well it would work for deep text scripting. Anyway, I hope you get some use out of it.
In an older post and in my 101 Autodesk Maya Tips, I talked about how you can send UNIX standard output to Maya via its commandPort and I just made a tool that batch generates previews for files using an open session of Maya. I made something similar in the past but it was slow because it launched a new session of Maya for each file via command line rendering. This is very quick because it just tells an already-open app to make a new scene, import the file, kick out an antialiased viewport 2 render to JPEG, wash, rinse and repeat.
Here is the Automator workflow file to install. Don’t rename it because it contains a shell script (stmaya) that bounces commands to Maya. You need to enable commandPort on port 2222 before Maya will accept input from the action. Do it with this command (I put this line in userSetup.mel so it is executed on Maya’s launch):
commandPort -n ":2222";
The only thing to keep in mind is that the script sets the imported file folder to your working project directory, so just remember to change it to your desired project after you’re done batching or you’ll be rendering into the last-previewed /tmp folder. Also, save your existing open work before you start doing these because it uses the “file -f -new” command meaning it won’t prompt you to save if you have an open doc with unsaved changes.
If you’re on Linux, you can do a similar thing with the two shell scripts that the Automator action uses. This is the script that operates on your input 3D file and this is the stmaya script that passes standard output to Maya. It’s a bit of a hairy combo that would be much nicer as one Python script but I am just updating existing bash scripts.
Sorry, Windows users – there’s no way to pipe standard output to Maya from the command prompt in Windows, so this can’t be adapted for non-UNIX OSes.
When Maya crashes, it tries to save out a file to a temp folder that you can recover on relaunch. In my 101 Autodesk Maya Tips I mention how you can get this file to open in Maya without digging through temp folders on Mac/Win/Linux but it seems that, due to what I think is V-Ray’s redirection of standard output, I no longer get the path of the crash file in the system log. So, I’m updating the script to work more like the Linux version. It does the exact same thing but by parsing the TMPDIR environment variable:
Grab the updated shell script or Automator Service which doesn’t require a terminal. Just open it from the Services menu in OS X.. After Maya 2014 is out, I’ll be releasing an updated version of 101 Autodesk Maya Tips to incorporate this change and I’ll add some new tips as well. Existing owners should receive the updated copy for free.
I mentioned a while ago that Maya 2013 breaks compatibility with older versions since it added some data to the Maya ASCII format that the other versions don’t understand. Well, it seems that this is pretty easily addressed with a simple find and replace in a text editor. The offending flag is “-ch #####”, where the ### is any number of whatever length. To make 2013 scenes compatible with older Maya versions, just replace that flag and the space after it with nothing:
If you have a text editor that supports regular expressions, use a regular expression in the find field and replace all with nothing. This is what that would look like:
Note that there is a space at the end after the “" that you can’t see – In BBEdit, regular expressions are referred to as GREP, the Unix app that finds things by regular expressions. I’m using BBEdit and it’s really good with giant text files like these but I went a step further and made a shell script for OS X and Linux that just does it all in one step with sed and saves out a file at the same location with a “_2012_compatible.ma” extension. Anyway, you can see it all works perfectly in this video:
Update: There is now a Python version of the stripper script that works with Windows as well as OS X and Linux. Thanks to Dhruv Govil for that. The Python script can be run from within Maya or from a command line. To run it from a command line, enter “python /path/to/stripper_2013.py /path/to/scene.ma”. Check the script contents on how to run it from within Maya.
I also made an Automator action for OS X that does the same thing:
Grab that here.
If you don’t know what version the document was created with, I made another Automator action that reads Maya ASCII files and tells you what it is with Growl:
Grab that here. It requires the growlnotify command line app be installed in /usr/local/bin/
5 notes | Permalink
There are some Windows thumbnail apps for Maya docs that get mixed results and cost cash money. I just whipped up something that uses Maya itself to generate a hardware rendered preview for selected .ma or .mb files (it also works on OBJ, FBX, etc):
It’s just a shell script that can be adapted to work in Linux as well as OS X (and Windows if you use Cygwin).
Here’s the shell script (run it by doing path/to/script.sh file1.mb file2.ma file3.obj)
Grab the Automator workflow here.
Both the shell script and Automator actions reference Maya 2012 on OS X. Just change the path to reference your Maya version.
Update: I made a revised version that renders the preview to /tmp and uses QuickLook to preview the document, for less clutter:
Grab it here: QuickLook_Maya.workflow