discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Copying objects?

FV
Frank van der Hulst
Tue, Nov 21, 2017 8:26 AM

I'd suggest generalising it a little more to making a
linear_pattern([x[,y[,z]]], [a,b,c]) function that repeats it's children on
a 2D or even 3D grid. And then also a revolve_pattern() function that
repeats it's children around the origin.

On 21/11/2017 20:57, "Troberg" troberg.anders@gmail.com wrote:

I've made a useful helper function that places a number of wood screws at a
certain distance (I show declaration only, just to show what I'm doing):

module screwseries(screwlength,screweddistance,spacing,center)

It puts a line of screwlength long screws, that is screweddistance long,
with spacing distance between each screw. If center=true, I center it along
the center point od the screwdistance.

Fairly straightforward.

Then, I noticed that I need to do the same with other objects. Metal screws,
nuts, washers, threaded bars and so on. Suddently, I need to duplicate code.

So, I thought, wouldn't it be nice if I could just make a module i call like
this:

objectseries(totallength,spacing,center){
bolt(80,10);
}

It would take the supplied object(s) and make copies of it, distributing
them evenly along that line. No longer would it be restricted to a single
type of object, and I can make neat code by separating placement from object
design.

Possible?

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I'd suggest generalising it a little more to making a linear_pattern([x[,y[,z]]], [a,b,c]) function that repeats it's children on a 2D or even 3D grid. And then also a revolve_pattern() function that repeats it's children around the origin. On 21/11/2017 20:57, "Troberg" <troberg.anders@gmail.com> wrote: I've made a useful helper function that places a number of wood screws at a certain distance (I show declaration only, just to show what I'm doing): module screwseries(screwlength,screweddistance,spacing,center) It puts a line of screwlength long screws, that is screweddistance long, with spacing distance between each screw. If center=true, I center it along the center point od the screwdistance. Fairly straightforward. Then, I noticed that I need to do the same with other objects. Metal screws, nuts, washers, threaded bars and so on. Suddently, I need to duplicate code. So, I thought, wouldn't it be nice if I could just make a module i call like this: objectseries(totallength,spacing,center){ bolt(80,10); } It would take the supplied object(s) and make copies of it, distributing them evenly along that line. No longer would it be restricted to a single type of object, and I can make neat code by separating placement from object design. Possible? -- Sent from: http://forum.openscad.org/ _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org