Copy link to clipboard
Copied
Hello All,
There is a "Place..." item in "File -> ...". If we can click on "Place...", "Place" dialog will open and asks for .ai file to place the whatever the art is there in that file in the current document. Right.
Now what I want is, if I click on one of the button in my plugin UI, "Place" dialog will open and art will be drawn in the current document.
I looked into the API documentation and found AIPlacedSuite::ExecPlaceRequest( ) function, but no use.
How can I open "Place" dialog from my plugin?
You can use "execve". This example will copy /tmp/file1 to /tmp/file2
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
pid_t forkPid;
char *childargs[] = { "cp", "/tmp/file1", "/tmp/file2", 0 };
if( ( forkPid = fork() ) == 0 ) {
execve( "/bin/cp", childargs, NULL );
} else if( forkPid > 0 ) {
printf( "Success!" );
} else {
printf( "Can't fork" );
}
For more information, man execve.
Copy link to clipboard
Copied
The SDK does not provide any calls to open the Place dialog directly.
You have a few potential solutiuons, however.
A. Implement your own file dialog box, and use the Place suite. Which I think is perhaps the most elegant solution.
B. Programitcally create an action that opens the Place dialog. You can record an action that does this to see what file would have to be written (see "Insert Menu Item..." then type "Place", enter while recording). Then you could call the action with the Action suite.
C. The dialog could be opened using the scripting capabilites (for instance AppleScript). Your program could then write/call the AppleScript. I know it can be done with AppleScript, and I suspect other scripting languages such as Java might be able to do it.
Hope this helps.
Copy link to clipboard
Copied
I think, there is no API which executes the script from a plugin in AI CS4. Right?
Then how can we open "Place..." dialog with the scripting capabilities?
Copy link to clipboard
Copied
Oddly enough this is related to something I just filed to Adobe as a bug in the SDK. Not only can you not trigger the menuitem 'Placed...', you can't detect when its invoked. Its just plain missing from AIMenuCommands.h
Copy link to clipboard
Copied
You can execute a script by, well, executing it.
On Mac OS X you can use 'fork' and 'exec' or 'execv' (or another variant) - they are defined in <unistd.h>. I have that working in an Illustrator plugin, so let me know if you are on Mac OS X and I can provide you with sample code.
On Windows, I am sure it is possible, but I do not know what you would call.
Copy link to clipboard
Copied
yes, could you please provide me the sample code?
Copy link to clipboard
Copied
You can use "execve". This example will copy /tmp/file1 to /tmp/file2
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
pid_t forkPid;
char *childargs[] = { "cp", "/tmp/file1", "/tmp/file2", 0 };
if( ( forkPid = fork() ) == 0 ) {
execve( "/bin/cp", childargs, NULL );
} else if( forkPid > 0 ) {
printf( "Success!" );
} else {
printf( "Can't fork" );
}
For more information, man execve.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now