• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Add a feature - Line length

New Here ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

Is it possible to add the information of line length on curved lines and also have the ability to lock that line segment yet still able to drag around the anchor points constrained to the fixed/lock length. Also add the feature of displaying in the info window the line length of any line segment in a line from anchor point to anchor point.

Would it be possible to add some sort of conversion tool that allows someone to take full illustrations a scale them to architectural scales. but does not affect the scaling of the illustration. some sort of window that has preset scale measurements.

Thanks

Jim Billings
TOPICS
SDK

Views

14.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guide ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

I'm not quite sure what you're asking, but at least part of it sounds like you're wondering if you can display the length of a path in the Info window. If that's what you're asking, no, that's not possible. Nothing stops you from creating your own small palette to display such information though.

As for constraining the ability to edit parts of a path, no, you can't do that either. You might be able to construct a custom art type that let you do that, but it wouldn't be considered path art by Illustrator. If that's okay though, you might check out the AIPluginGroup suite.

> Would it be possible to add some sort of conversion tool that
> allows someone to take full illustrations a scale them to
> architectural scales. but does not affect the scaling of the
> illustration. some sort of window that has preset scale
> measurements.

Again, I'm not quite sure I follow. It kind of sounds like the work we do with MAPublisher, at least a little. If so, I'm guessing 'yes', but I'm not 100% sure since I don't quite understand what you're trying to do.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

Not sure your understanding what I am asking for. Example is if you have a circle. what is the length of the line that makes up the circle.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 23, 2008 Jun 23, 2008

Copy link to clipboard

Copied

If you're just trying to calculate that value in page units, there's a function AIPathSuite::GetPathLength() that should give you the length in *points*. You'll have to convert that to whatever units you want that in (be it inches, millimeters, centimeters, etc.). From what I remember, this should work for bezier lines as well.

If that doesn't work for some reason, I can point you to some example code that would let you do that yourself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 01, 2016 Nov 01, 2016

Copy link to clipboard

Copied

Dear Patterson,

  Is Any iilustrator SDK methods available to convert Points(pt) Unit in to Millimeter (mm) Units.

Please give your Suggestion.

Thank You Friend,

Nathan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 01, 2016 Nov 01, 2016

Copy link to clipboard

Copied

LATEST

The new API lets you get results in whatever the current ruler unit is set to. ai::AutoCoordinateSystem in AIAutoCoordinateSystem.h lets you do this, at least in one of the later SDKs.

Failing that, you could do what we do, namely hardcode the conversion constants:

const AIReal kPointsPerInch = 72.0;

const AIReal kPointsPerPica = 12.0;

const AIReal kInchesPerCentimeter = 0.393700787f;

const AIReal kPointsPerCentimeter = kInchesPerCentimeter * kPointsPerInch;

const AIReal kCentimetersPerMillimeters = 0.1f;

const AIReal kPointsPerMillimeters = kCentimetersPerMillimeters * kPointsPerCentimeter;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2008 Aug 28, 2008

Copy link to clipboard

Copied

Could you please explain better the function you are talking about? I don't quite understand how to get there. I'm having the same issue, I need to find out the length of a line. I was told that exporting the illustrator file to autocad, would do the trick, but I'm having problems doing it from CS3. If tehre is a way to find the lenght in Illustrator, it would be great!
Thanks,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 29, 2008 Aug 29, 2008

Copy link to clipboard

Copied

The AIPathSuite has function GetPathLength() that will get you the length of any path in points. Just pass it the handle of the line and you'll get your length value back. If you want that value in something other than points you'll have to convert it from points to whatever. That part you'll have to do yourself I think, but then there are well known conversion values for all the document units Illustrator uses.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 04, 2009 Nov 04, 2009

Copy link to clipboard

Copied

Re: getPathLength

Any chance you could provide correct syntax or usage for this function? (or link to documentation, can't find in docs in AI scripting folder)

Do I need to #Include any special suite or anything? (I'm a total newb to jsx although some experience with JS in other contexts)

Is this for straight paths or curved also? One segment length or many?

Thanks in advance for any advice

Alastair

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 04, 2009 Nov 04, 2009

Copy link to clipboard

Copied

JSX? If you're doing this via scripting, you may want to try the forum over here:

http://forums.adobe.com/community/illustrator/illustrator_scripting

This forum is for the C/C++ SDK

As for what GetPathLength() returns, it returns the length of path, not individual segments, and yes it works for both flat & curved (bezier) paths.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 05, 2009 Nov 05, 2009

Copy link to clipboard

Copied

Thanks I realised after I posted this hit had come from SDK (even though I was searching Scripting folder!). Thanks.

In JS the pathObjectCalledThis.length property worked effortlessly, even on curves and multi-segment lines.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2008 Aug 29, 2008

Copy link to clipboard

Copied

I use the routine below in my tool JLG.Dimension (http://perso.orange.fr/jlg.outils) to calculate the length of a Bezier curve.<br />This is my little contribution to this discussion. To obtain the length as a string, you have to use a routine to convert a AIReal number into a string.<br />I hope this will help somebody.<br /><br />extern void BezierLength(AIArtHandle *path, short unit, AIReal scale, char BezierlengthText[])<br /> {//Calculate in BezierlengthText the total length of the Bezier curve (path). The result is a string.<br /> //If unit is 0 the length will be mm, 1 cm, 2 inches, 3 points, 4 picas and 5 for meters. <br /> AIErr error=kNoErr;<br /> long i, j;<br /> short pathCount, NtS;//NtS for number to string.<br /> AIBoolean IsClosed;<br /> AIRealBezier PtBezier;<br /> AIPathSegment Pt1, Pt2;<br /> //At the beginning, the length is zero.<br /> AIReal LengthOfBezier=0.0;<br /> <br /><br /> error = sPath->GetPathSegmentCount(*path, &pathCount );<br /> //If the path analyzed is closed, it will be necessary to add the length of the last part of the Bezier curve. <br /> error=sPath->GetPathClosed(*path, &IsClosed);<br /><br /> for(j=0;j<pathCount-1;j++)<br /> {//One point and the next point.<br /> error = sPath->GetPathSegments( *path, j, 1, &Pt1);<br /> error = sPath->GetPathSegments( *path, j+1, 1, &Pt2);<br /><br /> PtBezier.p0.h=Pt1.p.h;<br /> PtBezier.p0.v=Pt1.p.v;<br /> <br /> PtBezier.p1.h=Pt1.out.h;<br /> PtBezier.p1.v=Pt1.out.v;<br /><br /> PtBezier.p2.h=Pt2.in.h;<br /> PtBezier.p2.v=Pt2.in.v;<br /><br /> PtBezier.p3.h=Pt2.p.h;<br /> PtBezier.p3.v=Pt2.p.v;<br /><br /> LengthOfBezier+=sBezier->Length(&PtBezier, 1.0);<br /> }<br /><br /> if(IsClosed)<br /> {//The path is closed, we must calculate the length of the last segment (point 0 and point pathCount-1).<br /> error = sPath->GetPathSegments( *path, 0, 1, &Pt1);<br /> error = sPath->GetPathSegments( *path, pathCount-1, 1, &Pt2);<br /><br /> PtBezier.p0.h=Pt1.p.h;<br /> PtBezier.p0.v=Pt1.p.v;<br /><br /> PtBezier.p1.h=Pt1.in.h;<br /> PtBezier.p1.v=Pt1.in.v;<br /><br /> PtBezier.p2.h=Pt2.out.h;<br /> PtBezier.p2.v=Pt2.out.v;<br /><br /> PtBezier.p3.h=Pt2.p.h;<br /> PtBezier.p3.v=Pt2.p.v; <br /> LengthOfBezier+=sBezier->Length(&PtBezier, 1.0);<br /> }<br /><br /> //At this moment, LengthOfBezier contains the total length of the curve but the unit used is the point.<br /> switch(unit)<br /> {case 0://millimeters.<br /> LengthOfBezier=LengthOfBezier* 25.4 / 72.0 / scale;<br /> //Transform the length into a string.<br /> NtS=NumberToString(LengthOfBezier, BezierlengthText);<br /> //Add the unit.<br /> std::strcat(BezierlengthText, " mm");<br /> break;<br /> case 1://centimeters.<br /> LengthOfBezier=LengthOfBezier* 2.54 / 72.0/ scale;<br /> //Transform the length into a string.<br /> NtS=NumberToString(LengthOfBezier, BezierlengthText);<br /> //Add the unit.<br /> std::strcat(BezierlengthText, " cm");<br /> break;<br /> case 2://Inches.<br /> LengthOfBezier=LengthOfBezier/ 72.0 / scale;<br /> //Transform the length into a string.<br /> NtS=NumberToString(LengthOfBezier, BezierlengthText);<br /> //Add the unit.<br /> std::strcat(BezierlengthText, " in");<br /> break;<br /> case 3://Points.<br /> LengthOfBezier=LengthOfBezier/ scale;<br /> //Transform the length into a string.<br /> NtS=NumberToString(LengthOfBezier, BezierlengthText);<br /> //Add the unit.<br /> std::strcat(BezierlengthText, " pt");<br /> break;<br /> case 4://Picas.<br /> LengthOfBezier=LengthOfBezier/ 12.0/ scale;<br /> //Transform the length into a string.<br /> NtS=NumberToString(LengthOfBezier, BezierlengthText);<br /> //Add the unit.<br /> std::strcat(BezierlengthText, " pi");<br /> break;<br /> case 5://Meters.<br /> LengthOfBezier=LengthOfBezier * 0.0254 / 72.0 / scale;<br /> //Transform the length into a string.<br /> NtS=NumberToString(LengthOfBezier, BezierlengthText);<br /> //Add the unit.<br /> std::strcat(BezierlengthText, " m");<br /> break;<br /> default:<br /> break;<br /> }<br /> }<br /><br />JLG.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines