Hi I have developed a plugin for AI CC 2015.3 for both Win and Mac. There is a scenario in my plugin where have to export selected objects inside a loop. I couldn't find a direct method in the API for it. So, here is what I have done, I copy the selection, create a new document, paste it there, export the whole document as png, close it, and repeat the process for the next group. AICommandID copyCommand; error = sAICommandManager->GetCommandIDFromName(kCopyCommandStr, ©Command); error = sAIMenu->InvokeMenuAction(copyCommand); AICommandID cutCommand; AIErr error = sAICommandManager->GetCommandIDFromName(kCutCommandStr, &cutCommand); error = sAIMenu->InvokeMenuAction(cutCommand); AICommandID undoCommand; error = sAICommandManager->GetCommandIDFromName(kUndoCommandStr, &undoCommand); error = sAIMenu->InvokeMenuAction(undoCommand); AIDocumentHandle docHandle; AINewDocumentPreset p; ai::UnicodeString preset; ai::UnicodeString pres("Print"); error = sAIDocList->GetPresetSettings(pres, &p); error = sAIDocList->New(preset, &p, kDialogNone, &docHandle); AICommandID pasteCommand; error = sAICommandManager->GetCommandIDFromName(kPasteInPlaceCommandStr, &pasteCommand); error = sAIMenu->InvokeMenuAction(pasteCommand); error = ExportPieces(note); //error = sAIDocList->Close(docHandle); AICommandID closeCommand; error = sAICommandManager->GetCommandIDFromName(kCloseCommandStr, &closeCommand); error = sAIMenu->InvokeMenuAction(closeCommand); AICommandID deselectCommand; error = sAICommandManager->GetCommandIDFromName(kDeselectallCommandStr, &deselectCommand); The above happens inside a loop. Here is the Export method, AIErr ManageExport::ExportPieces(std::string noteName) { AIErr result = kNoErr; AIActionParamValueRef valueParameterBlock = NULL; ActionDialogStatus dialogStatus = kDialogNone; try { result = sAIActionManager->AINewActionParamValue(&valueParameterBlock); if (valueParameterBlock) { std::string pathName; #ifndef UNICODE pathName = MyPlugin::MYPATH; pathName.append("/export/"); #else std::wstring wStr = MyPlugin::MYPATH; pathName = std::string(wStr.begin(), wStr.end()); pathName.append("\\export\\"); #endif pathName.append(noteName); pathName.append(".png"); result = sAIActionManager->AIActionSetString(valueParameterBlock, 'name', pathName.c_str()); result = sAIActionManager->AIActionSetString(valueParameterBlock, 'frmt', "Adobe PNG Format"); result = sAIActionManager->AIActionSetString(valueParameterBlock, 'extn', "png"); result = sAIActionManager->PlayActionEvent(kAIExportDocumentAction, dialogStatus, valueParameterBlock); result = sAIActionManager->AIDeleteActionParamValue(valueParameterBlock); } } catch (ai::Error& ex) { result = ex; } return result; } However, when I execute it, it just exports the latest selection. What am I doing wrong? Can anyone guide me please?
... View more