Get area of an entity in Script Shell

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
Full Member
Posts: 84
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Get area of an entity in Script Shell

Post by dfriasb » Sun Sep 24, 2017 5:36 pm

I started scripting and using Script Shell. I managed to get x&y coordinates of lines start&end points and other information, but I cannot get areas. I tried "entity.getArea()", but it looks like this function doesn't exist.
This is the code I'm using:

Code: Select all

var doc = EAction.getDocument();
var entityIds = doc.queryAllVisibleEntities();
entityIds = doc.getStorage().orderBackToFront(entityIds);
for (var i = 0; i < entityIds.length; ++i) {
    var entity = doc.queryEntity(entityIds[i]);
    var pline = "" + entity.getId() + " ";
    if (isPolylineEntity(entity)) {
        pline += entity.getArea() + ",";
Any help will be very welcomed!
David Frías Barranco | architect |

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

Re: Get area of an entity in Script Shell

Post by andrew » Sun Sep 24, 2017 10:42 pm

I've added getArea to the RPolylineEntity API for the next release. For now you can use getArea of the underlying RPoltyline shape instead:

Code: Select all


Post Reply

Return to “QCAD Developers and Contributors”