17 Replies Latest reply on Sep 10, 2017 10:02 PM by nathans47916809

How To Distinguish Line,circle and Arcs in Current Document

Dear Friends,

I am having path Arts in the current document.

I read all the Path Arts by the Following code.

ASErr error=kNoErr;

AIArtSet artSet = NULL;

AIArtSet SelectartSet=NULL;

AIArtSpec specs[1] = {{kPathArt,0,0}};

error = sAIArtSet->NewArtSet(&artSet);

error = sAIArtSet->MatchingArtSet(specs, 1, artSet);

size_t numArts = 0;

sAIArtSet->CountArtSet(artSet, &numArts);

Is It possible to find the Art is Circle or Line or Arc?.

if it is Possible,give me your suggestions.

Thank you Friends,

Nathan

• 1. Re: How To Distinguish Line,circle and Arcs in Current Document

No, there's no help for you there I'm afraid. You'd have to do the math to determine what you're looking at -- which is not something I'd recommend frankly The best you can usually do is to iterate over the points and see if any of them are bezier or not (i.e. are thei n & out points the same as p?) -- that at least lets you rule our circle or arc.

But no, there's no classification. The AIPathSegment design encompasses all and does not try to classify; frankly, it would be very difficult to do it (personally, I don't think it's feasible).

• 2. Re: How To Distinguish Line,circle and Arcs in Current Document

Cumon, mister President Patterson, it's as easy as 1 2 3 :-)

Line - 2 points, zero area; circle - check the relation between length and area(you know, 2pi*r, pi*r*r); arc - 2 points, the same, boring.

I'm playing now with sine curves,this is a real pain in the back fun.

• 3. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

please explain more about how to calculate the Area(If Circle means Area= pi*r*r,How to find r here), And How to distinguish between Line And Arc.

Thank you friend,

Nathan.

• 4. Re: How To Distinguish Line,circle and Arcs in Current Document

As Mr Patterson says it is not simple.

You say you want to classify art as line, arc or circle, but a single piece of art can be made up of thousands of points.

What is a circle? Is an ellipse a circle? How about an ellipse whose width is 100 mm and height is 99.9 mm?

What is an arc? You could approximate an arc with lots of short straight line segments. Is that an arc?

What is a path that includes both straight line and bezier segments?

• 5. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

I distinguish Arc and Line by as you said

if in & out points the same as p then it is Line

else it is Curve(Arc,Circle or Ellipse).

How to Calculate the Arc's Centerpoint,Radius,Start Angle and End Angle Using p and in and out Points.

Thank You Friend,

Nathan

• 6. Re: How To Distinguish Line,circle and Arcs in Current Document

From the theoretical point of view, circles and real arcs (as well as sine curves) can not be drawn using cubic bezier curves (Michael Goldapp, "Approximation of circular arcs by cubic polynomials").

The radial error in this approximation by bezier curves will be about 0.0273% of the circle's radius.

So the answer could be: circles and arcs can not be "distinguished" as it's not possible to draw them in illustrator.

But we live in the real world. So the keyword here is tolerance.

• 7. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

I want to create My Own DXF(consist of Lines and Arcs) for the Current Document in the illustrator By Using illustrator API..

Is Any method availabe in Illustrator API to get the Curve points which is to be used to Create DXF or Any mathematic formulae available to calculate line and arc properties From Bezier Points or Segments.

AIPathSegment segment;

sAIPath->GetPathSegments( artCurrent, nCurSegment, 1, &segment );

AIRealBezier bezier;

sAIPath->GetPathBezier(artCurrent, nCurSegment,&bezier);

Thank You Friend,

Nathan.

• 8. Re: How To Distinguish Line,circle and Arcs in Current Document

Why don't you just use AIDocument::WriteDocument to save the current document as DXF?

• 9. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

I want to create DXF as R12 Version.

If I try to save as DXF manually illustrator shows the DXF version From R13.please see the image given below.

How to save the DXF as R12 by code.Is any options available?.

Thank you Friend,

Nathan

• 10. Re: How To Distinguish Line,circle and Arcs in Current Document

The earliest version supported by Illustrator is R13. Why do you want to save as a 25 year old file format?

• 11. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

We are having a  plugin that exports DXF as R12 Format,Now I want to implement the Same for the latest versions of illustrator.

So only i want to save it as R12 Format.

Thank You Friend,

Nathan

• 12. Re: How To Distinguish Line,circle and Arcs in Current Document

What do you do with the exported R12 DXF files? Are they used by software that is so old it can't read any newer version?

Where did the old plugin come from? Do you have the source code?

If you really want to export DXF R12 from current versions of Illustrator, it would probably be easier to export as R13 and then write code to convert that to R12 rather than trying to write code to convert an Illustrator document to DXF R12. Do you know what the difference is between R12 and R13 DXF formats?

• 13. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

We don't have source code.

How to save as R13 version DXF by code.If I use AIDocument::WriteDocument then how to set R13 Version.

Thank You Friend,

Nathan.

• 14. Re: How To Distinguish Line,circle and Arcs in Current Document

You should be able to use DxfDwgExportPrefs (AIDxfDwgPrefs.h) in an action manager PlayActionEvent call in the same way as  PSDExportPrefs. It sounds like PSDExportPrefs doesn't work anymore. I have never tried to use either:

• 15. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

I tried AIDxfDwgPrefs in Adobe Illustrator CC version.  But it doesn't work.

Is it possible to set the version by Using AIActionSetInteger Method.?.If it possible what is the versionKey to DXF Export Operation. see  the following code.

sAIActionManager->AIActionSetInteger(paramValueRef, 'versionKey', eR13);

Thank You Friend,

Nathan

• 16. Re: How To Distinguish Line,circle and Arcs in Current Document

I don't think you can set the version using the action manager. I tried saving two actions, one saving as R13 and the other saving as R14, but they don't include any version settings and when you replay the actions, they just use whatever the last setting was. You might be able to get it to work by overwriting the DXF preference before you do the save (should really restore the previous setting afterwards):

• 17. Re: How To Distinguish Line,circle and Arcs in Current Document

Dear Friend,

Thank you For You help.

Its Works Fine to save in R13 Version.

And Im having a doubt,Is there any options available to omit the Fill and Text Arts in the saving DXF File.Or Any options Available To Undo The number of Operation.That is  I remove All the Fills and Texts in the Current Document and Save it as DXF and Undo(Retain the Removed Fills and Text)?

Thank you Friend,

Nathan.