-
1. Re: Steps to add vector path objects to AI document
Toto RoToTO Oct 5, 2009 8:14 AM (in response to DavidShulman)1 person found this helpfulHi,
for source code samples, you could have a look at SnipperRunner project!
We could find a lot of cool stuff in here!
for the first point:
here it is a sample from the sdk:
try {
SDK_ASSERT(sAIActionManager);
SnpDocumentActionHelper::VPB vpb;
SnippetRunnerParameter* parameter = SnippetRunnerParameter::Instance();ai::UnicodeString documentName = parameter->GetString(ai::UnicodeString("Document name"), ai::UnicodeString("MyDocument"));
vpb.SetNewDocumentName(documentName);ai::FilePath profilesFolder;
result = sAIFolders->FindFolder(kAIUserWritableStartupFileFolderType, false, profilesFolder);
aisdk::check_ai_error(result);
ai::FilePath defaultPresetFilePath = profilesFolder;
defaultPresetFilePath.AddComponent(ai::FilePath(ai::UnicodeString("Print.ai")));
ai::FilePath presetFilePath = parameter->GetFilePath("New Document Profile", true, defaultPresetFilePath);
vpb.SetNewDocumentSettingsFile(presetFilePath);SnpChooser chooser;
AIDocumentColorModelValue documentColorModel = chooser.PickDocumentColorModel();
vpb.SetNewDocumentColorModel(documentColorModel);ASReal documentWidth = parameter->GetReal("Document width", 612.0);
vpb.SetNewDocumentWidth(documentWidth);ASReal documentHeight = parameter->GetReal("Document height", 792.0);
vpb.SetNewDocumentHeight(documentHeight);AIDocumentRulerUnitValue documentRulerUnit = chooser.PickDocumentRulerUnit();
vpb.SetNewDocumentRulerUnits(documentRulerUnit);AIRasterResolution rasterResolution = chooser.PickDocumentRasterResolution();
vpb.SetNewDocumentRasterResolution(rasterResolution);AIPreviewMode previewMode = chooser.PickPreviewMode();
vpb.SetNewDocumentPreviewMode(previewMode);result = this->NewDocument(kDialogOff, vpb);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex) {
result = ex;
}for the second point, you could do as follow:
ASErr result = kNoErr;
try {
// Create new art item in the document.
result = sAIArt->NewArt(kPathArt, kPlaceAboveAll, NULL, &artHandle);
aisdk::check_ai_error(result);// Define path segments.
AIPathSegment segment = {{0,0},{0,0},{0,0},false};
segment.corner = false;
short i = 0;
segment.p.h = 300;
segment.p.v = 300;
segment.in.v = 200;
segment.in.h = segment.out.h = segment.p.h;
segment.out.v = 400;
result = sAIPath->SetPathSegments(artHandle, i++, 1, &segment);
aisdk::check_ai_error(result);segment.p.h = 400;
segment.p.v = 400;
segment.in = segment.out = segment.p;
result = sAIPath->SetPathSegments(artHandle, i++, 1, &segment);
aisdk::check_ai_error(result);segment.p.h = 500;
segment.p.v = 300;
segment.in.v = 400;
segment.in.h = segment.out.h = segment.p.h;
segment.out.v = 200;
result = sAIPath->SetPathSegments(artHandle, i++, 1, &segment);
aisdk::check_ai_error(result);// Keep path open.
result = sAIPath->SetPathClosed(artHandle, false);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex) {
result = ex;
}why do you to redraw the document?
is there a special need?
you do not have to do that after adding a new Art in the Artwork tree.
Hope this will help you.
Regards,
Thomas.
-
2. Re: Steps to add vector path objects to AI document
DavidShulman Oct 5, 2009 8:30 AM (in response to Toto RoToTO)Hi Thomas,
Thanks for the prompt response, its really helpful - will check thios right away. I'm actually frantically reading through AI SDK...
What is a SnipperRunner, I cant find it in AI SDK. Any other place for download?
It seems I don't need to force document redraw - AI does this internally.
Best,
David
-
3. Re: Steps to add vector path objects to AI document
Toto RoToTO Oct 5, 2009 8:38 AM (in response to DavidShulman)1 person found this helpfulSnippetRunner is a sample project published in the AISDK.
If you have already downloaded it, you could find it, and some more in:
\Adobe_Illustrator_CS3_SDK\samplecode
\Adobe_Illustrator_CS4_SDK\samplecode
No need to redraw, let Illustrator do it for you!
Thomas.
-
4. Re: Steps to add vector path objects to AI document
DavidShulman Oct 5, 2009 12:21 PM (in response to Toto RoToTO)great, thanks!
I found snippets sample - checking out....
David