Use of for statement

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Use of for statement

devlaam
Hi List,

How do you make use of the "for" statement when creating
a list of points? Somehow i cannot get the syntax right:

Something like (pseudo code):

points = [ for(i=[0:5]) [cos(i*60),sin(i*60),0] ]

Such a structure can then be used in, for example a polygon.
(Of course, i can always expand this manually, but that is
not the idea).

Thx.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Use of for statement

nophead
Currently you can't but syntax like that has been proposed.


On 8 May 2013 14:02, Ruud Vlaming <[hidden email]> wrote:
Hi List,

How do you make use of the "for" statement when creating
a list of points? Somehow i cannot get the syntax right:

Something like (pseudo code):

points = [ for(i=[0:5]) [cos(i*60),sin(i*60),0] ]

Such a structure can then be used in, for example a polygon.
(Of course, i can always expand this manually, but that is
not the idea).

Thx.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Use of for statement

kintel
Administrator
On 2013-05-08, at 15:36 , nop head wrote:

> Currently you can't but syntax like that has been proposed.
>
Also, the bigger picture is to facilitate building (implicit) surfaces and solids programmatically.
One part of that is generating vertices, another part is generating connectivity information.
It would be interesting to think through some typical scenarios and propose a comprehensive syntax for making this possible.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Use of for statement

devlaam
In reply to this post by nophead
Cool! If points and lines are made independent 'objects' like cubes etc
no special for syntax is needed, and this would i think remove
the somewhat artificial difference between the two.


btw: by publishing the replies to posts naked on the web,
this list leaks a lot of personal information. Not cool!


On 08-05-13 15:36, nop head wrote:

> Currently you can't but syntax like that has been proposed.
>
>
> On 8 May 2013 14:02, Ruud Vlaming <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi List,
>
>     How do you make use of the "for" statement when creating
>     a list of points? Somehow i cannot get the syntax right:
>
>     Something like (pseudo code):
>
>     points = [ for(i=[0:5]) [cos(i*60),sin(i*60),0] ]
>
>     Such a structure can then be used in, for example a polygon.
>     (Of course, i can always expand this manually, but that is
>     not the idea).
>
>     Thx.
>     _______________________________________________
>     OpenSCAD mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://rocklinux.net/mailman/listinfo/openscad
>     http://openscad.org - https://flattr.com/thing/121566
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566
>

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Use of for statement

kintel
Administrator

On 2013-05-08, at 16:00 , Ruud Vlaming wrote:

> Cool! If points and lines are made independent 'objects' like cubes etc
> no special for syntax is needed, and this would i think remove
> the somewhat artificial difference between the two.
>
Some people build objects this way by creating simple polyhedrons (e.g. tetrahedrons) in a for loop and letting them union together into a solid object. See e.g. http://www.thingiverse.com/thing:8443

> btw: by publishing the replies to posts naked on the web,
> this list leaks a lot of personal information. Not cool!
>

I don't think we really leak a lot of information. You decide yourself under which name you send emails, and email addresses themselves are only visible to other mailing list members. The contents of emails to the list are naturally made available, as this is a public discussion.
If there has been any oversights, please give me some info about leaked information and I'll look into it.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Use of for statement

devlaam
On 08-05-13 16:11, Marius Kintel wrote:
>
> On 2013-05-08, at 16:00 , Ruud Vlaming wrote:
>
>> Cool! If points and lines are made independent 'objects' like cubes etc
>> no special for syntax is needed, and this would i think remove
>> the somewhat artificial difference between the two.
>>
> Some people build objects this way by creating simple polyhedrons
> (e.g. tetrahedrons) in a for loop and letting them union together
 > into a solid object. See e.g. http://www.thingiverse.com/thing:8443
Very nice, thanks for the link. I like the way openSCAD is organized
a lot. It is much more intuitive (for me at least) then other CAD
programs i used.

>> btw: by publishing the replies to posts naked on the web,
>> this list leaks a lot of personal information. Not cool!
>>
>
> I don't think we really leak a lot of information. You decide yourself
 > under which name you send emails, and email addresses themselves are
 > only visible to other mailing list members. The contents of emails to
 > the list are naturally made available, as this is a public discussion.
> If there has been any oversights, please give me some info about leaked
 > information and I'll look into it.
You are correct, this is my own fault. But i not have separate emails
for lists and personal communication. I think this is so for more
people. I saw you already remove the email address from the list
before publication. Maybe remove the complete first line:
   "On xx.xx.xx yyyyy wrote "
that would already make a big difference.




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566