How to get at individual children?

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

How to get at individual children?

xenomachina
Hello. I'm trying to write a module that will perform an operation on subsets of its children. I tried using children() with an index, but this still seems to give me all of the children. I'm seeing this behavior both with 2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.

Here's a simplified version of what I'm trying that illustrates the problem:

    module first() {
        child(0);
    }

    first() {
        for(i=[0:20:120]) {
            rotate([0,0,i]) translate([10,0,0]) cylinder();
        }
    }

The for loop generates 7 cylinders in an arc. I would expect the "first" module to then ignore all of them except the first, so I expect to see only one cylinder. Instead I see all 7.

I have tried using children() instead of child() and I have also tried using index=0 instead of just 0 as the parameter. Either way, the result is the same (except some don't compile on the older OpenSCAD binary).

Any ideas what I'm doing wrong?
Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

Miro Hrončok
You ar enot doing anything wrong, there is an implicit union()
happening after for().

See the note here:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#Intersection_For_Loop

And see this: https://github.com/openscad/openscad/issues/350

Miro Hrončok

Telefon: +420777974800


2015-02-24 0:02 GMT+01:00 xenomachina <[hidden email]>:

> Hello. I'm trying to write a module that will perform an operation on subsets
> of its children. I tried using children() with an index, but this still
> seems to give me all of the children. I'm seeing this behavior both with
> 2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I
> did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.
>
> Here's a simplified version of what I'm trying that illustrates the problem:
>
>     module first() {
>         child(0);
>     }
>
>     first() {
>         for(i=[0:20:120]) {
>             rotate([0,0,i]) translate([10,0,0]) cylinder();
>         }
>     }
>
> The for loop generates 7 cylinders in an arc. I would expect the "first"
> module to then ignore all of them except the first, so I expect to see only
> one cylinder. Instead I see all 7.
>
> I have tried using children() instead of child() and I have also tried using
> index=0 instead of just 0 as the parameter. Either way, the result is the
> same (except some don't compile on the older OpenSCAD binary).
>
> Any ideas what I'm doing wrong?
>
>
>
> --
> View this message in context: http://forum.openscad.org/How-to-get-at-individual-children-tp11738.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
|

Re: How to get at individual children?

nophead
In reply to this post by xenomachina
The problem is for always unions it children so there is only ever one child of first() and that is the for() node.

On 23 February 2015 at 23:02, xenomachina <[hidden email]> wrote:
Hello. I'm trying to write a module that will perform an operation on subsets
of its children. I tried using children() with an index, but this still
seems to give me all of the children. I'm seeing this behavior both with
2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I
did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.

Here's a simplified version of what I'm trying that illustrates the problem:

    module first() {
        child(0);
    }

    first() {
        for(i=[0:20:120]) {
            rotate([0,0,i]) translate([10,0,0]) cylinder();
        }
    }

The for loop generates 7 cylinders in an arc. I would expect the "first"
module to then ignore all of them except the first, so I expect to see only
one cylinder. Instead I see all 7.

I have tried using children() instead of child() and I have also tried using
index=0 instead of just 0 as the parameter. Either way, the result is the
same (except some don't compile on the older OpenSCAD binary).

Any ideas what I'm doing wrong?



--
View this message in context: http://forum.openscad.org/How-to-get-at-individual-children-tp11738.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
|

Re: How to get at individual children?

xenomachina
In reply to this post by Miro Hrončok
Ah, I see. Thanks.

Is there any workaround for this behavior? I tried rebuilding OpenSCAD in the issue350 branch and running it with the  --enable=lazy-union flag, but it still gives me 7 cylinders.


On Mon, Feb 23, 2015 at 3:07 PM, Miro Hrončok [via OpenSCAD] <[hidden email]> wrote:
You ar enot doing anything wrong, there is an implicit union()
happening after for().

See the note here:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#Intersection_For_Loop

And see this: https://github.com/openscad/openscad/issues/350

Miro Hrončok

Telefon: <a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800


2015-02-24 0:02 GMT+01:00 xenomachina <[hidden email]>:

> Hello. I'm trying to write a module that will perform an operation on subsets
> of its children. I tried using children() with an index, but this still
> seems to give me all of the children. I'm seeing this behavior both with
> 2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I
> did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.
>
> Here's a simplified version of what I'm trying that illustrates the problem:
>
>     module first() {
>         child(0);
>     }
>
>     first() {
>         for(i=[0:20:120]) {
>             rotate([0,0,i]) translate([10,0,0]) cylinder();
>         }
>     }
>
> The for loop generates 7 cylinders in an arc. I would expect the "first"
> module to then ignore all of them except the first, so I expect to see only
> one cylinder. Instead I see all 7.
>
> I have tried using children() instead of child() and I have also tried using
> index=0 instead of just 0 as the parameter. Either way, the result is the
> same (except some don't compile on the older OpenSCAD binary).
>
> Any ideas what I'm doing wrong?
>
>
>
> --
> View this message in context: http://forum.openscad.org/How-to-get-at-individual-children-tp11738.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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/How-to-get-at-individual-children-tp11738p11739.html
To unsubscribe from How to get at individual children?, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

nophead
No because children are not individual 3D objects, They are child nodes in the syntax tree.

E.g.

child(1) {
  a();
  b();
  c();
}

will select b(), which could generate many objects.

On 24 February 2015 at 20:53, xenomachina <[hidden email]> wrote:
Ah, I see. Thanks.

Is there any workaround for this behavior? I tried rebuilding OpenSCAD in the issue350 branch and running it with the  --enable=lazy-union flag, but it still gives me 7 cylinders.


On Mon, Feb 23, 2015 at 3:07 PM, Miro Hrončok [via OpenSCAD] <[hidden email]> wrote:
You ar enot doing anything wrong, there is an implicit union()
happening after for().

See the note here:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#Intersection_For_Loop

And see this: https://github.com/openscad/openscad/issues/350

Miro Hrončok

Telefon: <a href="tel:%2B420777974800" value="<a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800" target="_blank"><a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800


2015-02-24 0:02 GMT+01:00 xenomachina <[hidden email]>:

> Hello. I'm trying to write a module that will perform an operation on subsets
> of its children. I tried using children() with an index, but this still
> seems to give me all of the children. I'm seeing this behavior both with
> 2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I
> did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.
>
> Here's a simplified version of what I'm trying that illustrates the problem:
>
>     module first() {
>         child(0);
>     }
>
>     first() {
>         for(i=[0:20:120]) {
>             rotate([0,0,i]) translate([10,0,0]) cylinder();
>         }
>     }
>
> The for loop generates 7 cylinders in an arc. I would expect the "first"
> module to then ignore all of them except the first, so I expect to see only
> one cylinder. Instead I see all 7.
>
> I have tried using children() instead of child() and I have also tried using
> index=0 instead of just 0 as the parameter. Either way, the result is the
> same (except some don't compile on the older OpenSCAD binary).
>
> Any ideas what I'm doing wrong?
>
>
>
> --
> View this message in context: http://forum.openscad.org/How-to-get-at-individual-children-tp11738.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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/How-to-get-at-individual-children-tp11738p11739.html
To unsubscribe from How to get at individual children?, click here.
NAML



View this message in context: Re: How to get at individual children?

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
|

Re: How to get at individual children?

xenomachina
Yes, get that that's the behavior of for, though I honestly don't see how the implicit union is desirable, except for backward compatibility.

What I'm asking is: how can I create a sequence of 3D objects in a loop, and then iterate through them individually in a separate module? For example, is there a way to get at the individual children of a union?

Here's a more concrete example of what I'd like to be able to do:

    module hull_join() {
        union() {
            for_without_a_union (i=[0:$children - 2]) {
                hull() {
                    children(index=i);
                    children(index=i+1);
                }
            }
        }
    }

    hull_join() {
        for_without_a_union(i=[0:20:120]) {
            rotate([0,0,i]) translate([10,0,0]) cylinder();
        }
    }

If for_without_a_union existed, then this would create a set of cylinders in an arc and then hull_join would union together the hulls of each adjacent pair producing a round arc path. See this combined screenshot: https://imgur.com/MJjDlcY

To generate the left half of that screenshot I ended up manually unrolling the loop, but I'm hoping there's a way to use/implement hull_join that doesn't require unrolling loops, inlining the caller, or other sorts of special-casing.


On Tue, Feb 24, 2015 at 12:59 PM, nophead [via OpenSCAD] <[hidden email]> wrote:
No because children are not individual 3D objects, They are child nodes in the syntax tree.

E.g.

child(1) {
  a();
  b();
  c();
}

will select b(), which could generate many objects.

On 24 February 2015 at 20:53, xenomachina <[hidden email]> wrote:
Ah, I see. Thanks.

Is there any workaround for this behavior? I tried rebuilding OpenSCAD in the issue350 branch and running it with the  --enable=lazy-union flag, but it still gives me 7 cylinders.


On Mon, Feb 23, 2015 at 3:07 PM, Miro Hrončok [via OpenSCAD] <[hidden email]> wrote:
You ar enot doing anything wrong, there is an implicit union()
happening after for().

See the note here:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#Intersection_For_Loop

And see this: https://github.com/openscad/openscad/issues/350

Miro Hrončok

Telefon: <a href="tel:%2B420777974800" value="<a href="tel:%2B420777974800" value="<a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800" target="_blank"><a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800" target="_blank"><a href="tel:%2B420777974800" value="<a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800" target="_blank"><a href="tel:%2B420777974800" value="+420777974800" target="_blank">+420777974800


2015-02-24 0:02 GMT+01:00 xenomachina <[hidden email]>:

> Hello. I'm trying to write a module that will perform an operation on subsets
> of its children. I tried using children() with an index, but this still
> seems to give me all of the children. I'm seeing this behavior both with
> 2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I
> did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.
>
> Here's a simplified version of what I'm trying that illustrates the problem:
>
>     module first() {
>         child(0);
>     }
>
>     first() {
>         for(i=[0:20:120]) {
>             rotate([0,0,i]) translate([10,0,0]) cylinder();
>         }
>     }
>
> The for loop generates 7 cylinders in an arc. I would expect the "first"
> module to then ignore all of them except the first, so I expect to see only
> one cylinder. Instead I see all 7.
>
> I have tried using children() instead of child() and I have also tried using
> index=0 instead of just 0 as the parameter. Either way, the result is the
> same (except some don't compile on the older OpenSCAD binary).
>
> Any ideas what I'm doing wrong?
>
>
>
> --
> View this message in context: http://forum.openscad.org/How-to-get-at-individual-children-tp11738.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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/How-to-get-at-individual-children-tp11738p11739.html
To unsubscribe from How to get at individual children?, click here.
NAML



View this message in context: Re: How to get at individual children?

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



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/How-to-get-at-individual-children-tp11738p11749.html
To unsubscribe from How to get at individual children?, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

MichaelAtOz
Administrator
Have you considered recursion? (I haven't for your particular issue, brain not awake yet)
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

xenomachina
That's an interesting idea!

I just tried this...
 
    module segment(i, step, last) {
        rotate([0,0,i]) translate([10,0,0]) cylinder();
        if (i < last) segment(i + step, step, last);
    }

    hull_join() {
        segment(0, 20, 120);
    }

... and I still end up with something that looks a like the right image.

Something still seems to be making an implicit union. Is there some other approach that could avoid this?


On Tue, Feb 24, 2015 at 2:27 PM, MichaelAtOz [via OpenSCAD] <[hidden email]> wrote:
Have you considered recursion? (I haven't for your particular issue, brain not awake yet)
Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :)
Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/



If you reply to this email, your message will be added to the discussion below:
http://forum.openscad.org/How-to-get-at-individual-children-tp11738p11751.html
To unsubscribe from How to get at individual children?, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

Chow Loong Jin
On Tue, Feb 24, 2015 at 04:35:30PM -0700, xenomachina wrote:

> That's an interesting idea!
>
> I just tried this...
>
>     module segment(i, step, last) {
>         rotate([0,0,i]) translate([10,0,0]) cylinder();
>         if (i < last) segment(i + step, step, last);
>     }
>
>     hull_join() {
>         segment(0, 20, 120);
>     }
>
> ... and I still end up with something that looks a like the right image.
>
> Something still seems to be making an implicit union. Is there some other
> approach that could avoid this?
This doesn't work with arbitrary 3D objects, but will do what you want from one
child and a series of transformations:

-------------
use <scad-utils/transformations.scad>

module hull_join (transformations)
{
    for (i = [0 : len (transformations) - 2])
    hull () {
        multmatrix (transformations[i])
        children ();

        multmatrix (transformations[i + 1])
        children ();
    }
}

hull_join ([
        for (i = [0 : 20 : 120])
        rotation ([0, 0, i]) *
        translation ([10, 0, 0])
])
cylinder (d = 1, h = 20);
-------------

--
Kind regards,
Loong Jin

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

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

Chow Loong Jin
Also worth looking at is generalized extrusion along path:

 - https://github.com/openscad/openscad/issues/114
 - https://github.com/openscad/list-comprehension-demos

--
Kind regards,
Loong Jin

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

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

kintel
Administrator
In reply to this post by xenomachina
On Feb 24, 2015, at 15:53 PM, xenomachina <[hidden email]> wrote:

> Is there any workaround for this behavior? I tried rebuilding OpenSCAD in the issue350 branch and running it with the  --enable=lazy-union flag, but it still gives me 7 cylinders.
>
One of the reasons why #350 isn’t merged yet is because we haven’t resolved this properly.
There’s a suggestion to make such unpacking of nodes explicit:
https://github.com/openscad/openscad/wiki/OEP4%3A-Unwrap-Operator

Suggestions are welcome.

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

Re: How to get at individual children?

xenomachina
In reply to this post by Chow Loong Jin
On Tue, Feb 24, 2015 at 7:07 PM, Chow Loong Jin [via OpenSCAD]
<[hidden email]> wrote:
> This doesn't work with arbitrary 3D objects, but will do what you want from one
> child and a series of transformations:

Thanks! That's an interesting approach and solves my current problem.
That scad-utils library also looks extremely useful.

However, this raises some new questions for me...

I see "rotation" and "translation" are defined in
scad-utils/transformations.scad and are distinct from the built-in
rotate and translate modules. Are modules/functions not first-class?
Actually, I've been wondering why modules are even a separate kind of
thing from functions...
Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

doug.moen
In reply to this post by xenomachina
There is a detailed explanation of how shapes are passed as arguments to modules, in this document: https://github.com/openscad/openscad/wiki/OEP4%3A-Unwrap-Operator

This document explains the behaviour you are seeing with the 'for' statement. There's currently no way to access individual shapes in the Group returned by the 'for' statement; you'll have to write your program in a different way. The OEP4 proposes a language extension that I call the 'unwrap operator' that directly solves the problem you encountered. If this language extension were to be implemented, then your code could be made to work by adding an '&' in front of the 'for' statement:

    first() {
        & for(i=[0:20:120]) {
            rotate([0,0,i]) translate([10,0,0]) cylinder();
        }
    }

On 23 February 2015 at 18:02, xenomachina <[hidden email]> wrote:
Hello. I'm trying to write a module that will perform an operation on subsets
of its children. I tried using children() with an index, but this still
seems to give me all of the children. I'm seeing this behavior both with
2013.01+dfsg-2.2 (the latest binary in the Ubuntu 14.04 repo) and a build I
did myself from git commit 0dd3f004dd66798faef42ab4edaa72c12dc0ad66.

Here's a simplified version of what I'm trying that illustrates the problem:

    module first() {
        child(0);
    }

    first() {
        for(i=[0:20:120]) {
            rotate([0,0,i]) translate([10,0,0]) cylinder();
        }
    }

The for loop generates 7 cylinders in an arc. I would expect the "first"
module to then ignore all of them except the first, so I expect to see only
one cylinder. Instead I see all 7.

I have tried using children() instead of child() and I have also tried using
index=0 instead of just 0 as the parameter. Either way, the result is the
same (except some don't compile on the older OpenSCAD binary).

Any ideas what I'm doing wrong?



--
View this message in context: http://forum.openscad.org/How-to-get-at-individual-children-tp11738.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
|

Re: How to get at individual children?

clothbot
In reply to this post by kintel
How easily could render() be enhanced to output children?  That could be useful in other cases as a general-purpose "children generator", e.g. such as when importing 2D and 3D source material with a view to processing the sub-areas/volumes instead of the whole.

render(children=true) import("my_pile_of_volumes.stl");

Andrew.
Reply | Threaded
Open this post in threaded view
|

Re: How to get at individual children?

xenomachina
In reply to this post by kintel
On Tue, Feb 24, 2015 at 11:06 PM, kintel [via OpenSCAD]
<[hidden email]> wrote:
> There’s a suggestion to make such unpacking of nodes explicit:
> https://github.com/openscad/openscad/wiki/OEP4%3A-Unwrap-Operator
>
> Suggestions are welcome.

Thanks for the link. After reading OEP4, a number of things are
clearer to me. An explicit unwrap/unpack operator does seem like the
right approach.

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

Re: How to get at individual children?

xenomachina
In reply to this post by doug.moen
On Fri, Mar 13, 2015 at 5:40 AM, doug moen <[hidden email]> wrote:
> There is a detailed explanation of how shapes are passed as arguments
> to modules, in this document:
> https://github.com/openscad/openscad/wiki/OEP4%3A-Unwrap-Operator

Thanks. I finally got around to reading this carefully from beginning to
end. (I now get why you mentioned the JS-style "arguments" thing).

Overall, this idea seems great to me. Is there a timeline for
implementing it? (I'm pretty new to OpenSCAD, so I don't know the
process for OEPs.)

A few questions:

In one place it says,

    "A module is a kind of function that takes shapes as arguments, and
    returns a shape as a result."

Does a module really return one shape, or a group of shapes?

Also, it talks about the two argument lists of modules,

    "The inner argument list is surrounded by parentheses, and the
    arguments are values. The outer argument list is surrounded by
    braces, and the arguments are shapes."

Are shapes also values? That is, is it possible to have an inner
argument that I pass a shape to? Can I create an array/list of shapes?

As an aside, one thing I found a bit confusing when reading OEP4 was
that a few times it mentioned functions I've never heard of and could
not find documentation for, like flatten and append.  It might be nice
to link to further info about each of these the first time they are
mentioned.

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

Re: How to get at individual children?

doug.moen
Overall, this idea (OEP4) seems great to me. Is there a timeline for
implementing it? (I'm pretty new to OpenSCAD, so I don't know the
process for OEPs.)

There's a conflict between OEP2 and OEP4, and Marius indicated that
this is still an unresolved issue.
 
In one place it says,

    "A module is a kind of function that takes shapes as arguments, and
    returns a shape as a result."

Does a module really return one shape, or a group of shapes?

A module returns a single object, which is either a shape or a group (I consider a group to be a special kind of shape).
 
Also, it talks about the two argument lists of modules,

    "The inner argument list is surrounded by parentheses, and the
    arguments are values. The outer argument list is surrounded by
    braces, and the arguments are shapes."

Are shapes also values? That is, is it possible to have an inner
argument that I pass a shape to? Can I create an array/list of shapes?

No. Shapes and values live in disjoint universes. The two kinds of objects are computed during different phases of evaluation. I understand it would take a significant refactoring of the OpenSCAD internals to change this.
 
As an aside, one thing I found a bit confusing when reading OEP4 was
that a few times it mentioned functions I've never heard of and could
not find documentation for, like flatten and append.  It might be nice
to link to further info about each of these the first time they are
mentioned.

append() is a built-in function, and should be in the user manual. flatten() is an auxiliary function that I have seen people define in some source files to work around a deficiency in array comprehensions. I'm not sure if anybody has ever put flatten() into a library.

Doug Moen.

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

Re: How to get at individual children?

nophead
>append() is a built-in function
I don't think so in the latest release. Are you thinking of concat?

On 13 March 2015 at 20:42, doug moen <[hidden email]> wrote:
Overall, this idea (OEP4) seems great to me. Is there a timeline for
implementing it? (I'm pretty new to OpenSCAD, so I don't know the
process for OEPs.)

There's a conflict between OEP2 and OEP4, and Marius indicated that
this is still an unresolved issue.
 
In one place it says,

    "A module is a kind of function that takes shapes as arguments, and
    returns a shape as a result."

Does a module really return one shape, or a group of shapes?

A module returns a single object, which is either a shape or a group (I consider a group to be a special kind of shape).
 
Also, it talks about the two argument lists of modules,

    "The inner argument list is surrounded by parentheses, and the
    arguments are values. The outer argument list is surrounded by
    braces, and the arguments are shapes."

Are shapes also values? That is, is it possible to have an inner
argument that I pass a shape to? Can I create an array/list of shapes?

No. Shapes and values live in disjoint universes. The two kinds of objects are computed during different phases of evaluation. I understand it would take a significant refactoring of the OpenSCAD internals to change this.
 
As an aside, one thing I found a bit confusing when reading OEP4 was
that a few times it mentioned functions I've never heard of and could
not find documentation for, like flatten and append.  It might be nice
to link to further info about each of these the first time they are
mentioned.

append() is a built-in function, and should be in the user manual. flatten() is an auxiliary function that I have seen people define in some source files to work around a deficiency in array comprehensions. I'm not sure if anybody has ever put flatten() into a library.

Doug Moen.

_______________________________________________
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
|

Re: How to get at individual children?

doug.moen
Yes I'm thinking of concat. Sorry, I got OpenSCAD and Lisp mixed up in my head when I was writing OEP4. I'll need to update it now. Thanks for pointing out my error.

On 13 March 2015 at 16:53, nop head <[hidden email]> wrote:
>append() is a built-in function
I don't think so in the latest release. Are you thinking of concat?

On 13 March 2015 at 20:42, doug moen <[hidden email]> wrote:
Overall, this idea (OEP4) seems great to me. Is there a timeline for
implementing it? (I'm pretty new to OpenSCAD, so I don't know the
process for OEPs.)

There's a conflict between OEP2 and OEP4, and Marius indicated that
this is still an unresolved issue.
 
In one place it says,

    "A module is a kind of function that takes shapes as arguments, and
    returns a shape as a result."

Does a module really return one shape, or a group of shapes?

A module returns a single object, which is either a shape or a group (I consider a group to be a special kind of shape).
 
Also, it talks about the two argument lists of modules,

    "The inner argument list is surrounded by parentheses, and the
    arguments are values. The outer argument list is surrounded by
    braces, and the arguments are shapes."

Are shapes also values? That is, is it possible to have an inner
argument that I pass a shape to? Can I create an array/list of shapes?

No. Shapes and values live in disjoint universes. The two kinds of objects are computed during different phases of evaluation. I understand it would take a significant refactoring of the OpenSCAD internals to change this.
 
As an aside, one thing I found a bit confusing when reading OEP4 was
that a few times it mentioned functions I've never heard of and could
not find documentation for, like flatten and append.  It might be nice
to link to further info about each of these the first time they are
mentioned.

append() is a built-in function, and should be in the user manual. flatten() is an auxiliary function that I have seen people define in some source files to work around a deficiency in array comprehensions. I'm not sure if anybody has ever put flatten() into a library.

Doug Moen.

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

2015.03.14 and 2014.03 speed differences

yvette
In reply to this post by xenomachina
items being compared:

item (a):  round heatsink model
item (b):  rectangular bar with lettering
item (c):  round heatsink backer with a 1/4-20 screw thread

in all cases, $fn was set to 360
item (b) uses write.scad,  which (*iirc*) i glommed off thingiverse
item (c) uses thread.scad, which (*iirc*) i glommed off thingiverse


on 2015.03.14:

item (a) renders in 15 seconds
item (b) renders in 33 seconds
item (c) did not render on first run (info @ end of email);
          i "tweaked" the scad and then it ran in 2 min 9 sec.


on 2014.03:

item (a) renders in 16 seconds (1 second  slower than 2015.03.14)
item (b) renders in 42 seconds (9 seconds slower than 2015.03.14)
item (c) renders in  4 minutes 11 seconds.

so, to summarize, 2015.03.14 is faster and perhaps a bit "touchier".
the rulers are fab, and i'll be using 2015.03.14 from now on (unless
something doesn't render...)

hth and THANK YOU ALL for this product!
yvette


detail on item (c) go/nogo follows.

proper rendering of item (c) on 2015.03.14:

Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
Geometries in cache: 249
Geometry cache size in bytes: 576296
CGAL Polyhedrons in cache: 10
CGAL cache size in bytes: 99127184
Total rendering time: 0 hours, 2 minutes, 9 seconds
    Top level object is a 3D object:
    Simple:        yes
    Vertices:    10993
    Halfedges:   33594
    Edges:       16797
    Halffacets:  11474
    Facets:       5737
    Volumes:         2
Rendering finished.

proper rendering of item (c) on 2014.03:

Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
PolySets in cache: 13
PolySet cache size in bytes: 332792
CGAL Polyhedrons in cache: 25
CGAL cache size in bytes: 98274176
    Top level object is a 3D object:
    Simple:        yes
    Vertices:    10993
    Halfedges:   33594
    Edges:       16797
    Halffacets:  11474
    Facets:       5737
    Volumes:         2
Total rendering time: 0 hours, 4 minutes, 11 seconds
Rendering finished.


NB:  first run of item (c) using 2015.03.14 that did not render:

"Module cache size: 1 modules
Compiling design (CSG Tree generation)...
Compiling design (CSG Products generation)...
Geometries in cache: 13
Geometry cache size in bytes: 230888
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
WARNING: Normalized tree is growing past 4000 elements. Aborting
normalization.
WARNING: Normalized tree is growing past 4000 elements. Aborting
normalization.
Normalized CSG tree has 599 elements
Compile and preview finished.
Total rendering time: 0 hours, 0 minutes, 0 seconds"

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