License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

API Calculate polyline length

Miha Nahtigal
Advocate

Is there a simple way to fetch polyline length apart from looping through memo data, vertexes and arcs?

I couldn't find one... has anyone already been through this?

BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Miha Nahtigal
Advocate

I'll answer to myself...

 

// first point of memo.coords is dummy zeroes
for (short r = 2; r <= element.polyLine.poly.nCoords; r++) {
    segmentLength = sqrt(pow((*memo.coords)[r].x - (*memo.coords)[r - 1].x, 2) + pow((*memo.coords)[r].y - (*memo.coords)[r - 1].y, 2));
    arcIndex = FindArc(*memo.parcs, element.polyLine.poly.nArcs, r - 1);
    if (arcIndex >= 0) {
        // points with indexes r-1 and r are beginning and ending of an arc
        segmentLength = abs((*memo.parcs)[arcIndex].arcAngle) * segmentLength / 2 / sin(abs((*memo.parcs)[arcIndex].arcAngle)/2);
    }
    totalLength += segmentLength;
}
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.

View solution in original post

4 REPLIES 4
mthd
Ace

I am guessing that you already tried the measure tool ? I am not as skilled with Archicad as some are but there must be a way to determine the length of a complicated polyline in creating a bill of quantities somehow ?

AC8.1 - AC28 ARM AUS + CI Tools
Apple Mac Studio M1 Max Chip 10C CPU
24C GPU 7.8TF 32GB RAM OS Sequoia
Keep it Perpetual !

I am asking for C++ implementation inside an addon.

BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.
mthd
Ace

Whoops ! I didn’t check the category first. That’s something I know nothing about lol. I hope you get a reply here from someone who knows. Have fun.

AC8.1 - AC28 ARM AUS + CI Tools
Apple Mac Studio M1 Max Chip 10C CPU
24C GPU 7.8TF 32GB RAM OS Sequoia
Keep it Perpetual !
Solution
Miha Nahtigal
Advocate

I'll answer to myself...

 

// first point of memo.coords is dummy zeroes
for (short r = 2; r <= element.polyLine.poly.nCoords; r++) {
    segmentLength = sqrt(pow((*memo.coords)[r].x - (*memo.coords)[r - 1].x, 2) + pow((*memo.coords)[r].y - (*memo.coords)[r - 1].y, 2));
    arcIndex = FindArc(*memo.parcs, element.polyLine.poly.nArcs, r - 1);
    if (arcIndex >= 0) {
        // points with indexes r-1 and r are beginning and ending of an arc
        segmentLength = abs((*memo.parcs)[arcIndex].arcAngle) * segmentLength / 2 / sin(abs((*memo.parcs)[arcIndex].arcAngle)/2);
    }
    totalLength += segmentLength;
}
BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.