About   |   Getting Started   |   Downloads   |   Documentation   |   Forum


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CORE + Adobe's AI API
10-18-2014, 06:10 PM (This post was last modified: 10-18-2014 06:11 PM by Rick Johnson.)
Post: #1
CORE + Adobe's AI API
I could be very mistaken, but I get the impression in looking at some of the posts that CORE somehow includes the Adobe SDK given that it acquires those suites. Is it possible, if an Adobe suite is acquired for a given release, to make a direct call to that Adobe SDK suite within CORE (e.g. error = sAIPath->SetPathSegments( path, 0, 8, segments); )? Or to use existing Adobe SDK code, would I need to include the Adobe SDK in my project as well?

I'm porting several CS3 plugins to CS6 and it would be really, really nice to reuse as much existing code as I have, given that my main hurdle is the missing ADM. I can see this getting very messy, despite being able to reuse some of the code. I'm really at a crossroads as to which way to proceed. I should probably add that I'm an illustrator by profession, self-taught in C (and Pascal, REALbasic, AppleScript, etc.) from books and experimentation, so the simplest route for "real" programmers may not be the simplest route for me.

Also, I'd been getting away with keeping everything in the plain C (not C++) that I wrote for earlier versions and understand that this is still supported with Xcode, although perhaps not MS VC++. Any thoughts on this?

Thanks -- Rick
Find all posts by this user
Quote this message in a reply
10-19-2014, 11:15 AM
Post: #2
RE: CORE + Adobe's AI API
Yes, CORE does not require you to have the Illustrator SDK present, as it performs all necessary suite calls itself. This was one of the most important design goals of CORE; to start a new project, get one to compile for the latest release of Illustrator, and/or stop having to use preprocessor macros throughout your project to deal with separate versions of Illustrator, you simply download the latest version of CORE and get going. CORE handles all these differences internally and adds support for the latest version of Illustrator very close to the release date of Illustrator itself.

To support developers utilizing CORE and the Illustrator SDK in their project, we kept the declarations and definitions of suite globals internal to CORE, used an obfuscated global naming scheme, and do not distribute the Illustrator SDK alongside CORE. As such, you can't simply use e.g. the sAIPath global right out of the box, as CORE does not declare it for you. Similarly, CORE only acquires suites when they are needed, so you couldn't use our internal globals whenever you wanted.

So, to use the Illustrator SDK alongside CORE, you simply need to add the necessary version(s) of the Illustrator SDK to your project. This pretty much just involves you adding the Illustrator SDK header files search path to your project, creating some header that externs the suites you want to use, and create some *.c/*.cpp file to define the globals to a default value of NULL. Now you can acquire suites whenever you need to (startup, post-startup, etc.) No different really from creating a new project using the SDK way back before CORE existed.

And C++ is a superset of C, so the vast majority of C code is compilable with a C++ compiler. In fact, almost all modern C compilers are also C++ compilers. Your old C code is fine if you setup your project to compile against the Illustrator SDK, but CORE is mostly object-oriented so you will have to write some C++ code too if you want to use some CORE features.
Find all posts by this user
Quote this message in a reply
10-19-2014, 02:34 PM
Post: #3
RE: CORE + Adobe's AI API
Thanks, Garrett, I appreciate your taking the time for such a clear and thorough explanation! -- Rick
Find all posts by this user
Quote this message in a reply
09-20-2016, 09:21 PM
Post: #4
RE: CORE + Adobe's AI API
The various comments on the forum have been helpful, but I'm still not understanding something. I need to access the SDK's AITag suite (CS6) and put the relative path in my User Header Search Paths (in quotes because Adobe uses spaces in their folder names). Here's my header file:

Code:
#ifndef SDK_hpp
#define SDK_hpp

#include "AITag.h"
extern "C" AITagSuite*     sTag;
#endif /* SDK_hpp */

The header file generates no errors. And here's my .cpp file:

Code:
#include "SDK.hpp"
AITagSuite* sTag(NULL);
if (sTag == NULL){
    sSPBasic->AcquireSuite(kAITagSuite, kAITAGSuiteVersion, &sTag);
}

In the .cpp file, Xcode complains that in the "if" statement it expected an unqualified-id, and it thinks I'm trying to use "sSPBasic" as a type; that makes no sense to me. I also thought sSPBasic was automatically available. What am I overlooking?

Thanks -- Rick
Find all posts by this user
Quote this message in a reply
09-21-2016, 10:19 AM
Post: #5
RE: CORE + Adobe's AI API
Based on the post here, I made a copy of my Skeleton project and added this in SkelPlugin.cpp:

Code:
#include "SPBasic.h"
#include "AIUser.h"

AIUserSuite*    sAIUser(NULL);
extern "C" SPBasicSuite* sSPBasic;
...
void skel::Plugin::startup()
{
    sSPBasic->AcquireSuite(kAIUserSuite, kAIUserSuiteVersion, (const void**) &sAIUser);

Does the instruction - Add the Illustrator SDK headers to the Skeleton project" refer to adding the includes above, or are there files that need to be added by dragging their icons into my project window? In Xcode, targeting CS6 debug, I get no errors from the IDE, but upon building it, I get the error Adobe Illustrator CS6 SDK/illustratorapi/pica_sp/SPMdata.h:52: error: redefinition of 'struct SPMessageData'

At least I feel that I'm getting closer to actually acquiring SDK suites...
Find all posts by this user
Quote this message in a reply
09-25-2016, 10:47 PM
Post: #6
RE: CORE + Adobe's AI API
You're close. From your post on 9/20, you can't have bare logic like an `if` out in the open in a source file. Acquiring the suites inside a function like Plugin::startup() is the only way (like your post on 9/21).

My suggestion is to create a separate header, like you've done, to include all the necessary SDK files and declare the associated suite globals. Then, make this header file a "prefix header" in your Xcode project settings (same thing in Visual Studio on Windows once you're at that point).

Also in your Xcode project settings, add the "HDI_CORE_DONT_DECLARE_AI_TYPES" preprocessor definition to prevent CORE from declaring the various Illustrator SDK types it needs to operate (since you're including [some of] them yourself manually). Our Skeleton project already sets some preprocessor defs like "MAC_ENV" so you can just follow by example.

Lastly, don't forget to set your suite globals to `NULL` in some source file (which you can't do when you declare them with extern in your header).
Find all posts by this user
Quote this message in a reply
09-26-2016, 05:56 PM (This post was last modified: 09-27-2016 05:41 AM by Rick Johnson.)
Post: #7
RE: CORE + Adobe's AI API
That worked! Or at least it compiled. I'll list what I did in case I did something wrong, and if it's right it could be helpful to others.

- Added the path to Xcode's AI headers to the User Header Search Paths.
- Created a PCH file "SDKPrefixHeader.pch" in my "Headers" folder with the contents:

Code:
#ifndef SDKPrefixHeader_pch
#define SDKPrefixHeader_pch

#include "SPBasic.h"
#include "AIUser.h"
extern AIUserSuite*    sAIUser;
extern "C" SPBasicSuite* sSPBasic;

#endif /* SDKPrefixHeader_pch */

- Added the path and filename to the .pch file in Xcode's "Prefix Header" field.
- Added "HDI_CORE_DONT_DECLARE_AI_TYPES" to Xcode's Preprocessor Defines.

The first two lines in skelPlugin.cpp now read:

Code:
skel::Plugin* skel::Plugin::__instance = NULL;
AIUserSuite*    sAIUser = NULL;

Then I use the following in functions as appropriate:

Code:
sSPBasic->AcquireSuite(kAIUserSuite, kAIUserSuiteVersion, (const void**) &sAIUser);
...
sSPBasic->ReleaseSuite(kAIUserSuite, kAIUserSuiteVersion);

I'd rather take a simpler approach with a few #includes and declares in the Plugin.cpp file since I only need to make one call to the SDK, but until I understand how to do that without "redefine" errors, I'll stick with what works. Then again, since a copy of my Skel project is already set up, I'll have the option of easily accessing suites in new projects based on it.

Thank you, Garrett!
Find all posts by this user
Quote this message in a reply
09-28-2016, 07:19 PM
Post: #8
RE: CORE + Adobe's AI API
Oh no: Visual Studio doesn't have anything called a Prefix Header. It does have what's called a Forced Include File, though. Once I add that, I get dozens of strange and seemingly unrelated errors relating to the hdi::core headers:

Code:
hdicorePanel.h(152): error C2146: syntax error : missing ';' before identifier 'platformPanel'
hdicorePanel.h(152): error C2433: 'hdi::core::Panel::PlatformPanelPtr' : 'virtual' not permitted on data declarations
hdicorePanel.h(152): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hdicorePanel.h(152): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hdicorePanel.h(152): warning C4183: 'platformPanel': missing return type; assumed to be a member function returning 'int'
hdicoreCurrentDocument.h(128): error C2146: syntax error : missing ';' before identifier 'aiDocumentHandle'
hdicoreCurrentDocument.h(128): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hdicoreCurrentDocument.h(128): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hdicoreCurrentDocument.h(128): warning C4183: 'aiDocumentHandle': missing return type; assumed to be a member function returning 'int'
hdicoreaiDictionary.h(214): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
hdicoreaiDictionary.h(214): error C2146: syntax error : missing ',' before identifier 'aiDict_'
hdicoreaiDictionary.h(269): error C2146: syntax error : missing ';' before identifier 'aiDictionaryRef'

Maybe I should go back to the plain .h file method. When I remove the Prefix Header in Xcode, then include this header at either the top or end of my Plugin.cpp file includes:

Code:
#ifndef SDKHeader_h
#define SDKHeader_h
#include "SPBasic.h"
#include "AIUser.h"
#include "AITag.h"
extern AIUserSuite*    sAIUser;
extern AITagSuite*    sAITag;
extern "C" SPBasicSuite* sSPBasic;
#endif /* SDKHeader_h */

With or without "HDI_CORE_DONT_DECLARE_AI_TYPES" in the Preprocessor Definitions, I get:

Code:
... illustratorapi/pica_sp/SPMdata.h:52: error: redefinition of 'struct SPMessageData'

Undecided
Find all posts by this user
Quote this message in a reply
09-29-2016, 09:18 AM
Post: #9
RE: CORE + Adobe's AI API
"Forced include" is the same as "prefix" header. What might be a more complete, albeit verbose, name is "force-included prefix header".

The VS compiler is probably just complaining about unknown types that CORE normally declares for you, but the HDI_CORE_DONT_DECLARE_AI_TYPES constant turns that off. Include the proper AI SDK headers in your prefix header to resolve it (e.g. AIPanel.h).
Find all posts by this user
Quote this message in a reply
07-24-2017, 04:40 PM (This post was last modified: 07-24-2017 05:02 PM by Rick Johnson.)
Post: #10
RE: CORE + Adobe's AI API
(09-29-2016 09:18 AM)garrett Wrote:  Under the hood, CORE uses the AI SDK suites, so you can simply check if something like the sAIArt global is already acquired (and if not, acquire it yourself). If it is already acquired, do not overwrite it or release it, since CORE depends on it!

I find I'm making hybrid projects more often, and just want to make sure I'm doing this correctly and safely. As I understand, before acquiring a suite I should check if it has already been acquired by testing for a NULL pointer. If it has been acquired by CORE, will my, e.g., sAIUser which I set at NULL at startup, no longer be NULL, and available for use without acquiring it? If I acquire it, should I also set a bool variable to note for later that I acquired it and should therefore release it rather than leave it open for CORE to release? What are the rules for "playing nice" with regards to checking/acquiring/releasing suites with CORE?

Also, do I really need to make it a Prefix Header if I only reference it from the main plugin source file?

Many thanks! -- rj
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)