02-07-2018, 06:36 PM
This code seems to work, but can somebody tell me if I'm doing it correctly? Of course, I'll later add checks for whether the third party plugin (CADtools) is installed and its version is compatible. Also curious why the message() method returns an SPerr, returns another by reference, and d.SPCheck contains a third SPerr.
Code:
hdi::core::Illustrator::ThirdPartyPluginMap otherPlugins;
otherPlugins = HDI_CORE_ILLUSTRATOR->allPlugins();
hdi::core::Illustrator::ThirdPartyPluginMap::iterator it = otherPlugins.find("Hot Door CADtools");
// test "it" and bail if no pointer
hdi::core::ThirdPartyPlugin* CTpi = it->second;
std::string ctPIpath = CTpi->filePath(); // just to verify the plugin's pointer
// check plugin version and bail if prior to 11.1.2
hdi::ct::PublicMsgGetCurrentScaleData* data =
(hdi::ct::PublicMsgGetCurrentScaleData*)
HDI_CORE_ILLUSTRATOR->alloc(sizeof(hdi::ct::PublicMsgGetCurrentScaleData));
data->d.self = HDI_CORE_PLUGIN->spPluginRef();
data->layer = HDI_CORE_ILLUSTRATOR->currentDocument()->currentLayer()->aiLayerHandle();
SPMessageData* SPdata = reinterpret_cast<SPMessageData*>(data);
bool OKsoFar = CTpi->prepMessageData(*SPdata);
SPErr SPmsgErr, SPresult;
SPmsgErr = CTpi->message(hdi::ct::publicMsgCADtoolsCaller,
hdi::ct::publicMsgGetCurrentScaleSelector, SPdata, SPresult);
if (!SPmsgErr){
// read data from CADtools and store somewhere
double CTscaler CTscaler = data->scaler;
}
OKsoFar = CTpi->cleanMessageData(*SPdata);
HDI_CORE_ILLUSTRATOR->free(data);