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

User avatar
dfriasb
Full Member
Posts: 72
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Get area of an entity in Script Shell

Postby dfriasb » Sun Sep 24, 2017 5:36 pm

Hello,
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!
Regards,
David
David Frías Barranco | architect
dfriasb@gmail.com | davidfriasarquitecto.es

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

Re: Get area of an entity in Script Shell

Postby 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

entity.castToShape().getArea();


Return to “QCAD Developers and Contributors”

Who is online

Users browsing this forum: No registered users and 2 guests