View Full Version : open file with Photoshop from MEL?

05-08-2010, 04:38 PM
I'm trying to make a Windows-compatible version of a script that sends OBJ meshes to Photoshop CS5 for texturing (Mac version works: http://www.vimeo.com/11411280 ). It works fine if I drag and drop the file into Photoshop but my MEL code just launches PS from Maya and doesn't send the file for opening. Can anyone figure out where this is going wrong?:

file -force -options "(groups=1;ptgroups=1;materials=1;smoothing=1;normals=1"
-typ "OBJexport" -pr
-es "C:/GoP.obj";
system ("start C:/Program Files/Adobe/Adobe Photoshop CS5 \(64 Bit\)/Photoshop.exe C:/GoP.obj");

I'll build temp file names/paths later after the basic script works.

05-08-2010, 05:40 PM
ok - I have the command prompt command that works but still nothing in MEL:

start "" "%ProgramFiles%\Adobe\Adobe Photoshop CS5 (64 Bit)\Photoshop.exe" C:\GoP.obj

05-08-2010, 06:18 PM
is this not the correct syntax?

system( "start \"\" \"%ProgramFiles%/Adobe/Adobe Photoshop CS5 \(64 Bit\)/Photoshop.exe\" %TEMP%/GoP.obj");

It does nothing.

05-08-2010, 08:23 PM
I'm not sure the windows shell accepts or understands paths in /x/y/z slash format.. it may only work using \ backslashes (which means you'll have to do some knarly escaping!!)

also, what happens if the user has photoshop installed to a different folder?


05-08-2010, 09:32 PM
well I tried just Photoshop.exe and \ for paths but neither worked from the script. But like I said, Photoshop opens fine but the file just doesn't open.

I can get the OBJ to open easily by just using: system ("%TEMP%/GoP.obj");

But that requires that the owner of OBJ files be Photoshop. If someone can figure out how to make it work regardless of "open with" settings, I'd love to know how.

05-09-2010, 12:52 AM
hi dude, i scripted you a quick gui that asks for a photoshop.exe and an obj file and then loads it up on photoshop.

It works for me using photoshop cs4, vista, maya2009 sp1. Should work for you :D

if (`window -ex photoshopOBJLoad`) deleteUI photoshopOBJLoad;

window -wh 310 100 photoshopOBJLoad;
columnLayout -columnWidth 300;
rowLayout -columnWidth2 200 100 -numberOfColumns 2;
textField -width 200 psTF;
button -width 100 -label "<< Photoshop.exe"
-c "fileBrowser(\"PsExe\",\"Open\",\"\",0)";
setParent -u;
rowLayout -columnWidth2 200 100 -numberOfColumns 2;
textField -width 200 objTF;
button -width 100 -label "<< obj file"
-c "fileBrowser(\"objFile\",\"Open\",\"\",0)";
setParent -u;
columnLayout -columnWidth 300;
button -width 300 -label "Go !" -c "loadPsObj();";
setParent -top;

window -e -wh 310 100 photoshopOBJLoad;

global proc PsExe(string $filename, string $type)
textField -e -tx $filename psTF;

global proc objFile(string $filename, string $type)
textField -e -tx $filename objTF;

global proc loadPsObj()
string $psFile = toNativePath(`textField -q -tx psTF`);
string $objFile = toNativePath(`textField -q -tx objTF`);

system("start \""+$psFile+"\" \""+$objFile+"\"");

05-09-2010, 01:23 AM
you can try making a droplet that simply opens the file then run that

string $objPath = "%TEMP%\\GoP.obj";
system ("C:\\openOBJ.exe \"" + $objPath);

i used it to create gif sprite sheets out of renders before, don't know if it'll work in this situation.

05-09-2010, 04:12 AM
actually, since the OBJ loads fine if I just point to that without the PS part, I think I'll just keep what I have for Windows and remove the version-specific Photoshop code for OS X so users can just set the version of PS they want to use from the Finder/Explorer and then there's no concern about making multiple versions for CS4/CS5 or making people wade through dialogs when they would only want to set this once.

05-09-2010, 04:31 AM
Yeah, the whole point of the dialog thing was just in case the path to the Photoshop exe was different or something, so, hard coding it was a nono.

Nonetheless, whatever works for you dude.

05-09-2010, 06:15 AM
ya - thanks for that though. You went way beyond the call of duty with that one.

CGTalk Moderation
05-09-2010, 06:15 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.