I'm afraid I haven't. I looked to see how we were doing our image work and it's just via ExecPlaceRequest. I've never tried to relocate an image into kPluginArt, though I'm a little surprised it doesn't work. Maybe I shouldn't given the weirdness of kPluginArt.
I assume you tried the replacement method of ExecPlaceRequest. I've had cause to try it, but presumably you did and it didn't work either.
One other strange thing that's happening I don't quite understand. I've tried the following code to create a linked file in my plugin group:
AIArtHandle placedArtHandle = NULL;
sAIArt->NewArt(kPlacedArt, kPlaceInsideOnTop, pluginGroupResultHandle, &placedArtHandle);
AIErr err = sAIPlaced->SetPlacedFileSpecification(placedArtHandle, pathToMyFile);
After this runs, err = 376. This doesn't seem like it corresponds to an error code. I get the "Missing or modified files" message in Illustrator, but nothing on the canvas or the links panel.
Ok, so it looks like it was a hard/soft bounds issue that was placing the artwork off the canvas. I am successfully using the following code to place an external AI file inside my PluginGroup result art:
AIArtHandle placedArtHandle = NULL;
sAIArt->NewArt(kPlacedArt, kPlaceInsideOnTop, pluginArtResultGroup, &placedArtHandle);
sAIPlaced->SetPlacedBoundingBox(placedArtHandle, &bounds); //bounds is equal to the AIRect of my artboard.
sAIPlaced->SetPlaceOptions(placedArtHandle, kAsIs, kMidMid, FALSE);
AIErr err = sAIPlaced->SetPlacedFileSpecification(placedArtHandle, path);
AIArtHandle nativeArtHandle = NULL;
sAIPlaced->MakePlacedObjectNative(placedArtHandle, &nativeArtHandle, FALSE);
This basically works, however the art is not placed centered, at its original size in the artboard, as I would expect from the PlaceOptions I set. The final art is mirrored vertically above the artboard, and scaled to the horizontal size of the artboard bounds. I'm guessing this is a problem with the Matrix on some level, but that was all basically set using the suite functions. I'm still not sure I've got everything in the "right" order.
1 person found this helpful
That sounds familiar actually. I remember once that when I set the transform matrix of a placed raster to the identity, it ended up upside down, aligned to the right edge of the canvas, *above* the canvas. Knowing that, I could then proceed to put i where I actually wanted it (i.e. y-scale of -1, then transform & rotate).
According to the docs, the SetPlacedOptions(...) function is supposed to
Sets the placement options for a placed object, used to scale and place the linked image relative to the bounds of the placed object.
Placement is adjusted whenever the image size changes; that is, when the file changes on disk, or when it is explicitly relinked with SetPlacedFileSpecification().
It does not however seem to change anything, whether I call the function before or after SetPlacedFileSpecification(...) and no matter what options I use. In that documentation it also implies that there is a separate matrix for the PlacedArt object and the actual image linked in the PlacedArt. That seems to be backed up by the fact that GetPlacedDimensions(...) returns two matrices.
It would appear that SetPlacedOptions(...) is the only way to affect the linked image matrix, despite that function not doing anything in my testing.
There still seems to be some problem with how I'm placing my art. If I do not call MakePlacedObjectNative(...), the result is a linked file with nothing visible. If I embed the linked file using the Illustrator command, my file shows up as art objects. If I call MakePlacedObjectNative(...) in my code, the file shows up as art objects.
Making the object native is an acceptable solution for me, with the exception that it steals the art selection. I can add code to return the selection to whatever was previously selected.
I would still like to understand how to make this suite work the way the docs suggest it should though.
Looking at our code, we use AIPlacedSuite::Get/SetPlacedMatrix for linked images & AIRasterSuite::Get/SetRasterMatrix for rasters (or native objects).
A linked AI file is treated as a Raster?
No, it's treated as a kPlacedArt I believe. kRasterArt is what it becomes if it's made native.
Gah, my bad. No, a linked image becomes kRasterArt once it's made native. I actually have no idea about linked AI files. We only ever deal with linked or embedded images. Sorry for the confusion, it's been a long day
That makes more sense. The linked AI file becomes a group of paths and whatnot when it's embedded.
Ok, so my call to MakePlacedObjectNative(...) is breaking Undo/Redo as well. With that call intact, I can undo forever, but cannot redo. Without that call, both Undo and Redo maintain their usual functionality.
I guess it's back to the drawing board. I have to figure out how to make the placed AI file show on the canvas without embedding it.