Skip to main content
selvakkanit19061983
Known Participant
June 8, 2020
Answered

Apply color to Compound Path

  • June 8, 2020
  • 2 replies
  • 913 views

Dear Sir/ Madam.

 

Please teach us how to apply one AIColor to one Compound path?

 

Regards,

T.Selvakkani

This topic has been closed for replies.
Correct answer happy_personality5DE8

The below should work. I've only recently started using the SDK myself, but this works in my project:

#include "IllustratorSDK.h" //this is required for aisdk::check_ai_error
#include "Suites.h" //this should be your Suites acquisition file

AIPathStyle pathStyle;
AIPathStyleMap pathStyleMap;
AIDictionaryRef advStrokeParams = NULL;

//this line requires that art is currently selected
result = sAIPathStyle->GetCurrentPathStyle( &pathStyle, &pathStyleMap, &advStrokeParams, nullptr);

//you might be able to use this instead, as it does not require art to be selected, but I have not checked that it works as expected
result = sAIPathStyle->GetInitialPathStyle(&pathStyle); //will set pathStyle to the default values
aisdk::check_ai_error(result);
//set your options using the following lines as a template
pathStyle.fillPaint = true;
pathStyle.fill.color.kind = kGrayColor; 
pathStyle.fill.color.c.g.gray = kAIRealOne; //set colour to black

pathStyle.strokePaint = true;
pathStyle.stroke.color.kind = kGrayColor;
pathStyle.stroke.color.c.g.gray = kAIRealOne; //set colour to black
pathStyle.stroke.width = kAIRealOne; 
result = sAIPathStyle->SetPathStyle( YOUR_COMPOUND_PATH_ART_HANDLE, &pathStyle );
aisdk::check_ai_error(result);

 

Note that sAIPathStyle is a suite that must first be acquired. If you're using the SDK templates, which I think is a good idea, then that means you need to add AIPathStyleSuite to your Suites.h and Suites.cpp files. Good luck!!

2 replies

happy_personality5DE8
happy_personality5DE8Correct answer
Participant
June 10, 2020

The below should work. I've only recently started using the SDK myself, but this works in my project:

#include "IllustratorSDK.h" //this is required for aisdk::check_ai_error
#include "Suites.h" //this should be your Suites acquisition file

AIPathStyle pathStyle;
AIPathStyleMap pathStyleMap;
AIDictionaryRef advStrokeParams = NULL;

//this line requires that art is currently selected
result = sAIPathStyle->GetCurrentPathStyle( &pathStyle, &pathStyleMap, &advStrokeParams, nullptr);

//you might be able to use this instead, as it does not require art to be selected, but I have not checked that it works as expected
result = sAIPathStyle->GetInitialPathStyle(&pathStyle); //will set pathStyle to the default values
aisdk::check_ai_error(result);
//set your options using the following lines as a template
pathStyle.fillPaint = true;
pathStyle.fill.color.kind = kGrayColor; 
pathStyle.fill.color.c.g.gray = kAIRealOne; //set colour to black

pathStyle.strokePaint = true;
pathStyle.stroke.color.kind = kGrayColor;
pathStyle.stroke.color.c.g.gray = kAIRealOne; //set colour to black
pathStyle.stroke.width = kAIRealOne; 
result = sAIPathStyle->SetPathStyle( YOUR_COMPOUND_PATH_ART_HANDLE, &pathStyle );
aisdk::check_ai_error(result);

 

Note that sAIPathStyle is a suite that must first be acquired. If you're using the SDK templates, which I think is a good idea, then that means you need to add AIPathStyleSuite to your Suites.h and Suites.cpp files. Good luck!!

Legend
June 8, 2020

XCode or other programming language?, please provide details when asking, thanks.

selvakkanit19061983
Known Participant
June 8, 2020

Sorry! I used XCode programming in MAC OS.