Get line properties/values in script


#1

Hi,

I trying to get the properties for a line to use as input for changing the line.
Some of the values do not come as an object that I am able to use directly.
for example:
“line.lineType” gives [object LineType: 1]
and
“line.points” gives [object Point: (100.0, 150.0)],[object Point: (300.0, 200.0)]

How can I get the values as int, array or objects?

I am creating a small plugin.
One usage I have is to check if the line is Curved, then add two new midpoints,
Now I am getting the points by doing a split of the string and convert the string to int.
“coord = (String(line.points[0]).split(’(’).pop().split(’)’).shift()).split(’,’)”

I am looking for a better method and hopefully get the values directly.
Which property/object have I missed?

Thank you
Br
Bjorn


#2

Lines that connect 2 graphics do not have any geometry except for that it connects 2 graphics. That is why you can move objects and the lines grow or shrink to accommodate them. In this case, a Line is a graphic which is a vector, potentially connecting two other graphics at its head and tail ends.

See https://omni-automation.com/omnigraffle/lines-00.html for some examples of how to get all of the lines in a document. I hope that will help with the connecting lines, but differentiating when you have a stand alone Line defined by it’s geometry (so no connections) and when you have a line defined by it’s head and tail connections might be useful to think about.

Thanks,
Lanette


#3

Thank you for the information.
The line connect two graphics, and is created with myLine.connect(graphic1,graphic2)

After a break I found the obvious on accessing the points data/array. (How can I have missed that 🙂 )
myLine.points.lenght
myLine.points[0]
myLine.points[1]

var {x:startX,y:startY} = myLine.points[0]
var {x:endX,y:endY} = myLine.points[1]

lineType is not an array
How can I get the lineType as a value?

Thank you
Br
Bjorn