11 Replies Latest reply on Nov 3, 2016 12:58 PM by btempleton1982

    Creating PlacedArt inside PluginArt result art

    btempleton1982 Level 2

      I'm having some problems relating to creating a placed art and working with PluginGroup result art.

       

      I have been able to create a placed art using the ExecPlaceRequest(...) function in the placed art suite.

       

      I need to move the placed art into my plugin group result art group.

       

      Unfortunately, the ReorderArt(...) function in the AiArt suite returns 'PARM' error when I attempt to do so.

       

      Using the NewArt(...) function with the plugin group result art as the preposition works to put the new art inside the result group.

       

      The docs make it sound like there's a way to create a new art with the kPlacedArt type and then set the file specifications, etc. to actually link the file. However, all the ways I've tried of arranging the various functions don't result in the linked file actually appearing on the canvas.

       

      The best I've been able to do is get the "Linked file has been changed" message to appear, but nothing shows up on the canvas, or in the Links panel.

       

      Does anyone have any experience linking files using this method?

        • 1. Re: Creating PlacedArt inside PluginArt result art
          A. Patterson Level 4

          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.

          • 2. Re: Creating PlacedArt inside PluginArt result art
            btempleton1982 Level 2

            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.

            • 3. Re: Creating PlacedArt inside PluginArt result art
              btempleton1982 Level 2

              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);

              AIRealMatrix matrix;

              sAIPlaced->GetPlacedMatrix(placedArtHandle, &matrix);

              sAIHardSoft->AIRealMatrixRealHard(&matrix);

              sAIPlaced->SetPlacedMatrix(placedArtHandle, &matrix);

              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.

              • 4. Re: Creating PlacedArt inside PluginArt result art
                A. Patterson Level 4

                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).

                1 person found this helpful
                • 5. Re: Creating PlacedArt inside PluginArt result art
                  btempleton1982 Level 2

                  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.

                   

                  • 6. Re: Creating PlacedArt inside PluginArt result art
                    A. Patterson Level 4

                    Looking at our code, we use AIPlacedSuite::Get/SetPlacedMatrix for linked images & AIRasterSuite::Get/SetRasterMatrix for rasters (or native objects).

                    • 7. Re: Creating PlacedArt inside PluginArt result art
                      btempleton1982 Level 2

                      A linked AI file is treated as a Raster?

                      • 8. Re: Creating PlacedArt inside PluginArt result art
                        A. Patterson Level 4

                        No, it's treated as a kPlacedArt I believe. kRasterArt is what it becomes if it's made native.

                        • 9. Re: Creating PlacedArt inside PluginArt result art
                          A. Patterson Level 4

                          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

                          • 10. Re: Creating PlacedArt inside PluginArt result art
                            btempleton1982 Level 2

                            That makes more sense. The linked AI file becomes a group of paths and whatnot when it's embedded.

                            • 11. Re: Creating PlacedArt inside PluginArt result art
                              btempleton1982 Level 2

                              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.