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 ?
Coordinates of the extreme points of the selected line?
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
-
- Full Member
- Posts: 82
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
Re: Coordinates of the extreme points of the selected line?
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.
Please refer to scripts/Misc/MiscDraw/DrawBoundingBox/DrawBoundingBox.js for a complete example which draws bounding boxes around selected entities.
-
- Full Member
- Posts: 82
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
Re: Coordinates of the extreme points of the selected line?
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 ?
Is there any method / property that returns the X and Y coordinates of the vectors contained in the BoundingBox ?
Re: Coordinates of the extreme points of the selected line?
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:
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;
-
- Full Member
- Posts: 82
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
-
- Full Member
- Posts: 82
- Joined: Fri Apr 17, 2015 6:40 am
- Location: http://creativitainformaticart.altervista.org
Re: Coordinates of the extreme points of the selected line?
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;
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;