Any thoughts on a new command "children_for()"

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Any thoughts on a new command "children_for()"

royasutton
I often find myself generating objects using for() and later wanting to perform additional operations on individual child-objects of the result.

For example consider:

include <omdl-v0.6.1/omdl-base.scad>;
include <omdl-v0.6.1/database/geometry/polyhedra/polyhedra_all.scad>;

// table data
tc = dtc_polyhedra_polyhedra_all;
tr = dtr_polyhedra_polyhedra_all;

// get a list of row id's
idl = get_table_ridl(tr);

// generate a 6^3 grid of the 164 objects spaced 250^3
grid_repeat(6, 250) 
for (id = idl)
{
  c = get_table_v(tr, tc, id, "c");  // gets & scale coordinates, faces
  f = get_table_v(tr, tc, id, "f");
  v = coordinates_csc(c, 100);

  // generates an object
  polytope_frame(v, f) {circle(r=4); color("grey") sphere(r=6);}  
}

This does not work as expected since the loop returns a single child...

How difficult would it be to allow children generated inside the loop to be returned as a group of children rather than a single child? Either by adding a option to the for() command or introducing a new command "children_for()"...

Any thoughts?
Roy
tp3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

tp3
That's not a simple change, but certainly one from the "most
wanted" list.

See https://github.com/openscad/openscad/issues/350 for some
discussion about that...

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

codifies
In reply to this post by royasutton
Which is why I assume that each iteration is actually independent

On 07/04/17 22:17, royasutton wrote:

> I often find myself generating objects using for() and later wanting to
> perform additional operations on individual child-objects of the result.
>
> For example consider:
>
>
>
> This does not work as expected since the loop returns a single child...
>
> How difficult would it be to allow children generated inside the loop to be
> returned as a group of children rather than a single child? Either by adding
> a option to the for() command or introducing a new command
> "children_for()"...
>
> Any thoughts?
> Roy
>
>
>
> --
> View this message in context: http://forum.openscad.org/Any-thoughts-on-a-new-command-children-for-tp21116.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

codifies
In reply to this post by tp3
ah right so that does blow it out of the water, if unions are applied
each loop then each iteration isn't a truly independent event as I
thought it might be...

On 07/04/17 22:55, Torsten Paul wrote:

> That's not a simple change, but certainly one from the "most
> wanted" list.
>
> See https://github.com/openscad/openscad/issues/350 for some
> discussion about that...
>
> ciao,
>    Torsten.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

tp3
On 04/08/2017 12:37 AM, Mr C Camacho wrote:
> ah right so that does blow it out of the water, if unions are
> applied each loop then each iteration isn't a truly independent
> event as I thought it might be...
>
Not sure, but I don't think that's the case. One big challenge
is to get this working without breaking lots of existing
scripts. In general both parallel calculation and returning
the object list instead of the implicit union should be
possible, but needs quite some work.

ciao,
  Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

codifies
you can go too far with backwards compatibility - especially if to
update an old script needs only minimal changes.

I'm not saying this is they way to go, but equally it maybe shouldn't be
discarded out of hand...

On 08/04/17 00:05, Torsten Paul wrote:

> On 04/08/2017 12:37 AM, Mr C Camacho wrote:
>> ah right so that does blow it out of the water, if unions are
>> applied each loop then each iteration isn't a truly independent
>> event as I thought it might be...
>>
> Not sure, but I don't think that's the case. One big challenge
> is to get this working without breaking lots of existing
> scripts. In general both parallel calculation and returning
> the object list instead of the implicit union should be
> possible, but needs quite some work.
>
> ciao,
>    Torsten.
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

royasutton
In reply to this post by tp3
Just reading through the list at the wiki... Details... details... Thank you.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

Mihail Vasiliev
If you introduce a new grammar unit in some new major release, e.g. "every" which is equal to "for" but returns a list - you will break only the scripts, which already use this very word.

8 апр. 2017 г. 2:31 пользователь "royasutton" <[hidden email]> написал:
Just reading through the list at the wiki... Details... details... Thank you.



--
View this message in context: http://forum.openscad.org/Any-thoughts-on-a-new-command-children-for-tp21116p21122.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Any thoughts on a new command "children_for()"

nophead
I can't imagine many, if any, scripts relying on for to make one child and it would be very easy to fix by adding union and that would still work with older versions.

On 8 April 2017 at 21:41, Mihail Vasiliev <[hidden email]> wrote:
If you introduce a new grammar unit in some new major release, e.g. "every" which is equal to "for" but returns a list - you will break only the scripts, which already use this very word.

8 апр. 2017 г. 2:31 пользователь "royasutton" <[hidden email]> написал:

Just reading through the list at the wiki... Details... details... Thank you.



--
View this message in context: http://forum.openscad.org/Any-thoughts-on-a-new-command-children-for-tp21116p21122.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Loading...