Skip to main content
MustenJiruwala
Inspiring
August 29, 2024
Question

Implementing arrowheads in a line

  • August 29, 2024
  • 1 reply
  • 403 views

Hello 

We have been implementing Illustrator plugins since past 7 years. This is the first time we are phasing a problem with the documentation to implement arrowhead for a line!

 

The line is being drawn using

 

sAIShapeConstruction->NewLinePoint (oStart, oEnd, poHandle);

 

and stroke width and other things like colors can be done using AIPathStyles

 

sAIPathStyle->GetPathStyle(oArtHandle, &oPathStyle, &oAdvFill);
oPathStyle.stroke.width = 0.1 * kPointsPerMM;
sAIPathStyle->SetPathStyle (oArtHandle, &oPathStyle);

 

However, on both sides of the line, I need to implement arrowheads and I could not find any information in the SDK documentation as to how to implement that!

 

Can you please help?

 

Thank you

Musten Jiruwala

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
August 30, 2024

This is a bit annoying to do, but you basically have to get the path's AIArtStyle, parse it (AIArtStyleParser) get the stroke you want to update and then modify its paint field with the AIBeautifulStrokes::SetArrowheadOptions. The arrow heads themselves are a style you'll have to pull in somehow, and you apply something like this:

 

error = sAIBeautifulStrokes->SetArrowheadOptions(strokeEffectsDictionary, 0, &arrowHeadStyle, kAIRealUnknown, arrowHeadScale, alignment);

I'd post more code but (a) it's internal code I'm not allowed to share and (b) it's riddled with helper classes I've written to make this tedious code easier to manage. Hopefully that's enough to get you to where you need to be though.

A. Patterson
Inspiring
August 30, 2024

The Illustrator AI arrowheads are located in the Required Resources folder, which you can find using the AIFoldersSuite::FindFolder -- the one you want is kAIRequiredLocalizedResourcesFolderType. Once you have that path, it's Arrowheads.ai. You can use AIPathStyleSuite::ImportSytles() to get a document handle to the file, and use that with

AISymbolSuite::GetNthSymbolPatternFromDocument() to load specific arrowheads.