We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2022-09-28 08:04 PM
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?
Solved! Go to Solution.
2022-09-29 08:19 PM
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;
}
2022-09-29 04:28 AM - edited 2022-09-29 04:39 AM
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 ?
2022-09-29 07:23 AM
I am asking for C++ implementation inside an addon.
2022-09-29 08:31 AM
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.
2022-09-29 08:19 PM
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;
}