# Defining a line with its endpoints

**URL:** <https://forum.inductiveautomation.com/t/defining-a-line-with-its-endpoints/4985>\
**Category:** Ignition\
**Created:** [August 13, 2012, 5:58am UTC](https://forum.inductiveautomation.com/t/defining-a-line-with-its-endpoints/4985 "2012-08-13T05:58:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cas](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Cas](https://forum.inductiveautomation.com/u/Cas)\
**Post date:** [August 13, 2012, 5:58am UTC](https://forum.inductiveautomation.com/t/defining-a-line-with-its-endpoints/4985/1 "2012-08-13T05:58:30Z")

</div>

All,  
I am using a Python script to calculate the end points of a line segment, (x1, y1) and (x2, y2). I then want to change the endpoints of a line on my user’s window to equal those two points. How can I change the coordinates of a line segment’s endpoints via Python script (in the Developer I can edit the endpoints and stipulate their coordinates, but I want to do it programatically)?

Any guidance would be helpful. Thanks,

Cas

---

<div class="post-metadata">

**Author:** ![DomArmstrong](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@DomArmstrong](https://forum.inductiveautomation.com/u/DomArmstrong)\
**Post date:** [August 13, 2012, 1:27pm UTC](https://forum.inductiveautomation.com/t/defining-a-line-with-its-endpoints/4985/2 "2012-08-13T13:27:45Z")

</div>

Hi Cas,

I had a look for you and couldn’t work out a simple way to change a standard line, but you could have a look at the paintable canvas.

Here is a simple example of a line that you can tie to your dynamic properties. You would have to define custom properties on the paintable canvas component for ‘myX’, ‘myY’ which you can then update.

This code would go in the canvas’s event handler for paint/repaint. When you create a new canvas it comes pre-filled with a pump example which you can have a look at too.

[code]from java.awt.geom import Line2D

g = event.graphics  
line = Line2D.Float(0, 100, event.source.myX, event.source.myY)  
g.draw(line)[/code]

Hope this is of help.

Dom

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [August 13, 2012, 5:52pm UTC](https://forum.inductiveautomation.com/t/defining-a-line-with-its-endpoints/4985/3 "2012-08-13T17:52:03Z")

</div>

The paintable canvas solution is really going to be the best way to go. If there is some specific reason this solution won't work for you let me know.
