Skip navigation
Currently Being Moderated

GraphicLine Length

Aug 6, 2012 12:42 AM

Tags: #javascript #indesign_cs5 #linelength

Hi Experts,

           I'm trying to place a grahic line in side of particular lines of indesign document. For that I can set it in appropriate geometric bounds. I create a Graphic Line maually and save it in library. I place it whereever I need. The line's length is "40pt". While automation of placing the line from library, I need to change the length of that line. I tried a lot to change the length by codes. But not changed. But If i select it and change the line length manually, it changes. Can any one tell me the property to change the line length... The screenshot is shown below for changing manually...

line.GIF

 

 

Thanks and regards,

Vel.

 
Replies
  • Currently Being Moderated
    Aug 6, 2012 1:19 AM   in reply to Velprakash

    Did you try changing the geometricBounds?

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 6, 2012 1:55 AM   in reply to Velprakash

    Vel,

     

    As you can see in the object model, graphic lines have no length property, but they do have geometricBounds. So changing the length of a line is like changing the size of a text frame or rectangle using geometricBounds. Start a new document and place a vertical line. Then do this:

     

    line = app.documents[0].graphicLines[0];

     

    gb = line.geometricBounds;

    gb[2] += 6;

    line.geometricBounds = gb;

     

    The line is made a deeper -- how much deeper depends on your document's measurement units.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 6, 2012 5:26 AM   in reply to Velprakash

    Hi,

     

    if you'll really need the length of a graphic linesome day. you've got to do a bit math as ID does not provide the length although it's shown in the UI.

     

    You may use geometricBounds or pathPoint.anchor as below ...

     

    var myPathPoints = app.activeDocument.graphicLines[0].paths[0].pathPoints;

    //this is pythagoras, but you may use any other mathrule to solve ...

    myLength = Math.sqrt(Math.pow(myPathPoints[0].anchor[0] - myPathPoints[1].anchor[0], 2) + Math.pow(myPathPoints[0].anchor[1] - myPathPoints[1].anchor[1], 2) )

    alert(myLength)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points