Monday, March 29, 2010

Automation plugin: Get filename of...

Hello!

I'm writing a automation plug-in and i need to know where the location of the current active document is.

does anyone know how to get it?



thanks richard
Automation plugin: Get filename of...
Hi,



take a look at the ''propetizer'' plugin example that came with the sdk,

this plugin shows some properties of the current active doc including its path using the PropertyProcs Suite:



OSErr PIGetDocumentName(string %26amp; name)

{

Handle h = NULL;



OSErr error = sPSProperty-%26gt;getPropertyProc(kPhotoshopSignature,

propTitle, 0, NULL, %26amp;h);



if (!error %26amp;%26amp; h != NULL)

{

error = HandleToString(h, name);

sPSHandle-%26gt;Dispose(h);

}



return error;

}
Automation plugin: Get filename of...
hi!

this function only works with Photoshop on Windows systems.

On Mac I get only the filename without the path. is there another property which delivers the full path to the current document?



thanks in advance

ricahrd

Oh, you want the FULL path? ; ) Sorry, here's how to:



Look at the Getter-plugin example: ''install'' getter, launch photoshop, open a doc and start getter from the file menu - the log contains the full path both on mac and win.

Now take a look at the GetDocumentInfo() function - this gets all the available info/props from a doc using DumbInfoFromDescriptor() (defined in PIUActionUtils). The function loops through all open docs, retrieves their properties with DumbInfoFromDescriptor and stores them into the log-file.

The code in the ''case typeAlias:'' statement shows ho to get the full path from the mac alias (=%26gt;AliasToFullPath()) and the rest shows how to obtain the alias needed for this. All you have to do is clean the code so that it will only retrieve the full path and not all the other stuff and change it so that it doesn't store the path in a file but returns it to you instead.

No comments:

Post a Comment