Getting minimum / maximum coordinates or bounding box

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

Moderator: andrew

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

Getting minimum / maximum coordinates or bounding box

Post by andrew » Mon Apr 24, 2017 8:41 am

From a QCAD user:
How can I find out the bottom / left or minimum coordinate and the top / right or maximum coordinate of a drawing document?

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

Re: Getting minimum / maximum coordinates or bounding box

Post by andrew » Mon Apr 24, 2017 8:42 am

You can get the bounding box (bottom/left and top/right coordinates) of a loaded drawing document as follows (document is of type RDocument):

Code: Select all

var bbox = document.getBoundingBox();
The returned object is of type RBox:

Code: Select all

var bottomLeft = bbox.getMinimum();
var topRight = bbox.getMaximum();
Where bottomLeft and topRight are of type RVector:

Code: Select all

qDebug("minimum x: ", bottomLeft.x);
qDebug("minimum y: ", bottomLeft.y);

qDebug("maximum x: ", topRight.x);
qDebug("maximum y: ", topRight.y);

Post Reply

Return to “QCAD Developers and Contributors”