Coordinates of the extreme points of the selected line?

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Coordinates of the extreme points of the selected line?

Post by pietro_72_ » Sun May 15, 2016 7:43 am

Salve

Vorrei ottenere in javascript le coordinate dei punti estremi di una retta selezionata, come si deve fare?

C'è anche un modo, tramite pulsante, di richiamare la modalit

C'è anche un modo, tramite un pulsante, di richiamare la modalità di selezione?

Translated by google

Hello

I would get in javascript coordinates of the extreme points of the selected line , as it should do?

There is also a way , via a button, to call the selection mode ?

User avatar
andrew
Site Admin
Posts: 9052
Joined: Fri Mar 30, 2007 6:07 am

Re: Coordinates of the extreme points of the selected line?

Post by andrew » Tue May 17, 2016 8:03 am

You can get the bounding box of an entity using entity.getBoundingBox().

Please refer to scripts/Misc/MiscDraw/DrawBoundingBox/DrawBoundingBox.js for a complete example which draws bounding boxes around selected entities.

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: Coordinates of the extreme points of the selected line?

Post by pietro_72_ » Thu May 26, 2016 7:15 am

Bounding Box = Box (Vector ( 25 , 15 , 0 , true) - Vector ( 48 , 28 , 0 , true) )
Is there any method / property that returns the X and Y coordinates of the vectors contained in the BoundingBox ?

User avatar
andrew
Site Admin
Posts: 9052
Joined: Fri Mar 30, 2007 6:07 am

Re: Coordinates of the extreme points of the selected line?

Post by andrew » Thu May 26, 2016 8:05 am

You have:

box.getCorner1()
box.getCorner2()

or:

box.getMinimum()
box.getMaximum()

All of these return RVector objects. You can then use the x and y properties for the x/y values:
var box = new RBox(new RVector(0,0), new RVector(100,50));
var c1 = box.getCorner1();
var c2 = box.getCorner2();
var x1 = c1.x;
var y1 = c1.y;
var x2 = c2.x;
var y2 = c2.y;

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: Coordinates of the extreme points of the selected line?

Post by pietro_72_ » Fri May 27, 2016 7:09 am

thank you

pietro_72_
Full Member
Posts: 81
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: Coordinates of the extreme points of the selected line?

Post by pietro_72_ » Sat Jun 04, 2016 8:11 am

Risolto
Sono riuscito ad ottenere quello che volevo in questo modo:

Solved
I managed to get what I wanted in this way :

var ids = document.querySelectedEntities();
var i;
for (i=0; i<ids.length; i++) {
var id = ids;
var entity = document.queryEntity(id);
var x1 = entity.getEndPoints()[0].x;
var y1 = entity.getEndPoints()[0].y;
var x2 = entity.getEndPoints()[1].x;
var y2 = entity.getEndPoints()[1].y;

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”