### string to list

SL
Steve Lelievre
Tue, Jun 25, 2024 4:36 PM

Hi Ray,

Just a postscript to mention that cumulative summing of vector elements
can be done very compactly using list comprehensions.  I am not yet
proficient in working with list comprehensions so would struggle to
write the code myself, but fortunately there's an example in the
documentation. See "Cumulative sum of values in v" at

You end up with:

// points from wall distances
n = [0,1];s=[0,-1];e=[1,0];w=[-1,0];
p =
[e0,w8.5,s38,w5,w95,w110,w50,w4,n37,w75,n7,w44,s8,w52,w62,w70,w39,w69,w43,s90,e*726.5];

function cumsum(v) = [for (a = v[0]-v[0], i = 0; i < len(v); a = a+v[i],
i = i+1) a+v[i]];

polygon(cumsum(p));

//

Cheers,

Steve

On 2024-06-25 5:45 a.m., Raymond West via Discuss wrote:

Here's the code, for the north facing wall, and a bit of the two
sides. Thanks for the help. (and ChatGPT, who got there in the end)

// points from wall distances
n=[0,1];s=[0,-1];e=[1,0];w=[-1,0];
p=
[e0,w8.5,s38,w5,w95,w110,w50,w4,n37,w75,n7,w44,s8,w52,w62,w70,w39,w69,w43,s90,e*726.5];

function build_new_list(p, new = [[0, 0]]) =
len(new) > len(p) ? new :
let (last = new[len(new) - 1],
next = [last[0] + p[len(new) - 1][0], last[1] + p[len(new) -
1][1]])
build_new_list(p, concat(new, [next]));

new = build_new_list(p);
echo(old=p);
echo(new=new);

polygon(new);
////////////////////////////////////////////////////

On 25/06/2024 12:41, Raymond West via Discuss wrote:

Thanks for all your replies.  I've decided to go with Steve'sidea "A
quick and lazy way that I think would work" which at the moment suits
me fine, except the summing of the elements is going to need a
recursive function, at least, which tends to bother me. If I'm happy
with it, I'll post the code.

So far, excluding windows and doors, for the exterior of the
building, there are about 60 points to play with, but later, once the
proof of concept is completed, I will probably persuade ChatGPT to
write some python code, or something, to simplify all the data entry.
ChatGPT is OK at Python, at least for my purposes, but not so good
with openscad, where it becomes a battle of wills.

Best wishes,

Ray

To unsubscribe send an email todiscuss-leave@lists.openscad.org

To unsubscribe send an email todiscuss-leave@lists.openscad.org

RW
Raymond West
Sun, Jun 30, 2024 7:52 PM

Just thought I'd update.

just need to add roof-tiles, ridge-tiles, windows, doors, chimneys,
gutters and downpipes. I need to get the height of the roof. Maybe jury
rig a crude theodolite. Of course, the actual building is not exactly
square, and combined with my crude measuring system, it was interesting.
Not sure If I'll do much internal detail.

On 25/06/2024 13:45, Raymond West via Discuss wrote:

Here's the code, for the north facing wall, and a bit of the two
sides. Thanks for the help. (and ChatGPT, who got there in the end)

// points from wall distances
n=[0,1];s=[0,-1];e=[1,0];w=[-1,0];
p=
[e0,w8.5,s38,w5,w95,w110,w50,w4,n37,w75,n7,w44,s8,w52,w62,w70,w39,w69,w43,s90,e*726.5];

function build_new_list(p, new = [[0, 0]]) =
len(new) > len(p) ? new :
let (last = new[len(new) - 1],
next = [last[0] + p[len(new) - 1][0], last[1] + p[len(new) -
1][1]])
build_new_list(p, concat(new, [next]));

new = build_new_list(p);
echo(old=p);
echo(new=new);

polygon(new);
////////////////////////////////////////////////////

On 25/06/2024 12:41, Raymond West via Discuss wrote:

Thanks for all your replies.  I've decided to go with Steve'sidea "A
quick and lazy way that I think would work" which at the moment suits
me fine, except the summing of the elements is going to need a
recursive function, at least, which tends to bother me. If I'm happy
with it, I'll post the code.

So far, excluding windows and doors, for the exterior of the
building, there are about 60 points to play with, but later, once the
proof of concept is completed, I will probably persuade ChatGPT to
write some python code, or something, to simplify all the data entry.
ChatGPT is OK at Python, at least for my purposes, but not so good
with openscad, where it becomes a battle of wills.

Best wishes,

Ray