• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Replicating setting the 'file path' of a placed item in C++ SDK

New Here ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

I am attempting to implement an Illustrator (CC 2017 and above) plug-in which replicates the behavior of AppleScript's:

tell application "Adobe Illustrator"

  set file path of placed item 1 of document 1 to "/path/to/an/image"

end tell

Initially I tried using SetPlacedFileSpecification() from the AIPlacedSuite. However, it appears that it is not possible to switch from an EPS file to a raster file as it returns AIErr 376 which thanks to (Paul_A_George)​ in a response to a previous question "Problem Programmatically Placing Images with Placed or Raster Suites" is badEPSFileErr. The ability to switch between linked EPS and raster files is an absolute requirement.

After searching this forum I found 3 other issues that seem relevant, Creating PlacedArt inside PluginArt result art, How to relink a raster to a file by using SDK??​ and Placed image update​ which pointed me to the ExecPlaceRequest() also in AIPlacedSuite. I am now doing the following that appears to work:

AIPlaceRequestData lReplaceRequest;

lReplaceRequest.m_lPlaceMode = kForceReplace;

lReplaceRequest.m_hOldArt = lArtHandle;

lReplaceRequest.m_pFilePath = &lNewFilePath;

lReplaceRequest.m_filemethod = 1; // link

lReplaceRequest.m_disableTemplate = true; // necessary?

lReplaceRequest.m_doShowParamDialog = false;

lReplaceRequest.m_PlaceTransformType = kAIPlaceTransformTypeNone;

AIErr lErr = sAIPlaced->ExecPlaceRequest(lReplaceRequest);

What I am looking for is validation that this is correct and what the AppleScript calls.

Thanks in advance,

Nick   

TOPICS
SDK

Views

383

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

LATEST

A follow up to the above query is whether it is necessary to call:

AIBoolean lUpdated = false;

ThrowIfAIErr_(sAIArt->UpdateArtworkLink(lArtHandle, true, &lUpdated));

after the ExecPlaceRequest() to make sure that the link is completely updated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines