doug.moen wrote
Then I guess you need include instead of use.
Include doesn't work for the same reason as use. It needs to be placed in
part1.scad instead of part_test.scad.
--
Sent from: http://forum.openscad.org/
nophead wrote
Or pass part2 to part1 as a child.
Could you explain how to pass part2 to part1 as a child? I've already tried
to use children() to do what I want to do, and it didn't work, as I
described in this post:
children() doesn't work with objects generated in a for loop
http://forum.openscad.org/How-to-apply-changes-to-all-shapes-generated-in-a-for-loop-td23685.html
--
Sent from: http://forum.openscad.org/
I tested the following and it works for me.
part1.scad___________
module part1() {
echo("part1");
part2();
}
part2.scad___________
module part2() {
echo("part2");
}
part_test.scad_________
include <part1.scad>
include <part2.scad>
part1();
On 28 March 2018 at 12:09, jamcultur nyponen@gmail.com wrote:
doug.moen wrote
Then I guess you need include instead of use.
Include doesn't work for the same reason as use. It needs to be placed in
part1.scad instead of part_test.scad.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
children() doesn't work with objects generated in a for loop
Well yes and no. A for loop produces a union of all its iterations, so only
produces one child. I think modules do the same. Nothing can return
multiple children, you can only pass them explicitly as a list.
But for this case it would work to decouple part1 and part 2.
part1.scad___________
module part1() {
echo("part1");
children();
}
part2.scad___________
module part2() {
echo("part2");
}
part_test.scad_________
use <part1.scad>
use <part2.scad>
part1() part2();
On 28 March 2018 at 17:26, doug moen doug@moens.org wrote:
I tested the following and it works for me.
part1.scad___________
module part1() {
echo("part1");
part2();
}
part2.scad___________
module part2() {
echo("part2");
}
part_test.scad_________
include <part1.scad>
include <part2.scad>
part1();
On 28 March 2018 at 12:09, jamcultur nyponen@gmail.com wrote:
doug.moen wrote
Then I guess you need include instead of use.
Include doesn't work for the same reason as use. It needs to be placed in
part1.scad instead of part_test.scad.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
doug.moen wrote
I tested the following and it works for me.
part_test.scad_________
include
<part1.scad>
include
<part2.scad>
part1();
It didn't work when I first tested it because I had
use <part1.scad>
include <part2.scad>
I did that because I had some code in part1.scad that I didn't want to be
executed when the file was included. When I took that code out and included
both files, it worked. I think this might be the best solution for me and I
will continue testing it. Thank you!
--
Sent from: http://forum.openscad.org/
nophead wrote
children() doesn't work with objects generated in a for loop
Well yes and no. A for loop produces a union of all its iterations, so
only
produces one child. I think modules do the same. Nothing can return
multiple children, you can only pass them explicitly as a list.
But for this case it would work to decouple part1 and part 2.
part1.scad___________
module part1() {
echo("part1");
children();
}
part2.scad___________
module part2() {
echo("part2");
}
part_test.scad_________
use
<part1.scad>
use
<part2.scad>
part1() part2();
I haven't tested this yet to see if it will work with my code that generates
objects in a loop, but I will. Thanks.
--
Sent from: http://forum.openscad.org/
I don't think you can generate objects in a loop. It is always a single
object because the results are implicitly unioned. The only way I know to
get multiple children is to list them explicitly. E.g.
part1() {
part2();
cube();
sphere();
}
On 30 March 2018 at 16:08, jamcultur nyponen@gmail.com wrote:
nophead wrote
children() doesn't work with objects generated in a for loop
Well yes and no. A for loop produces a union of all its iterations, so
only
produces one child. I think modules do the same. Nothing can return
multiple children, you can only pass them explicitly as a list.
But for this case it would work to decouple part1 and part 2.
part1.scad___________
module part1() {
echo("part1");
children();
}
part2.scad___________
module part2() {
echo("part2");
}
part_test.scad_________
use
<part1.scad>
use
<part2.scad>
part1() part2();
I haven't tested this yet to see if it will work with my code that
generates
objects in a loop, but I will. Thanks.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 3/30/2018 10:19 AM, nop head wrote:
I don't think you can generate objects in a loop. It is always a
single object because the results are implicitly unioned. The only way
I know to get multiple children is to list them explicitly. E.g.
part1() {
part2();
cube();
sphere();
}
[ Just thinking out loud. This seems like an interesting idea; I'm not
pushing hard for it. ]
I wonder how reasonable it would be to have a construct that would take
a CSG tree and crack it apart into individual subtrees.
That is, "explode() union() { x; y; }" would be equivalent to "x; y;".
(For operations other than "union" maybe it would be an error, or maybe
the operation would be discarded.)
From a tree manipulation standpoint it seems plausible, and it seems
like it might be useful, e.g. allowing a wrapper module to pass its
children to an inner module as individual objects:
module inner() {
// do something with children
echo($children);
}
module outer() {
// do stuff, then invoke inner on the children
inner() explode() children();
}
outer() {
sphere();
cube();
}
would echo 2, not 1.
From a syntactic perspective, I'm bothered by having something that
looks like a module but yields more than one object. It seems like some
kind of different syntax would be desirable.
I tried nophead's solution in my code, and it worked. In case anyone is
interested, my code is a jewelry design program. I've made about 60 designs
with the previous version. Here is a pendant I designed with it that I cast
in sterling silver.
http://forum.openscad.org/file/t1635/AlienArthropod3.jpg
Although the previous version could be used to design a huge range of
geometric and fractal designs, there were things I wanted to do with it that
it couldn't do. The reorganized version is much more powerful, flexible, and
extendable. Here's a design I made to test the reorganized code. This design
would have been impossible with the previous version, but was easy with the
reorganized version.
http://forum.openscad.org/file/t1635/1a.png
http://forum.openscad.org/file/t1635/1b.png
I probably won't make this one in metal. It's not really my style. But I'm
excited about what I can now design.
--
Sent from: http://forum.openscad.org/
On Fri, Mar 30, 2018 at 06:19:27PM +0100, nop head wrote:
I don't think you can generate objects in a loop. It is always a single
object because the results are implicitly unioned.
In that case, that's a hint we should think about possibly chaiging
things in the language.
The C language was designed so that the basic functions do things that
are useful, but also that they don't do too much. For example, printf
does not automatically add a newline. writing a function to add that
is easy, building something that removes the newline is not.
So.... a list of objects is easily unioned by adding union in
front, while a unioned list is not easily un-unioned.
for (i=[0:10:50])
translate ([i,i,0]) cube (15);
should give me the list of 6 cubes, while
union () {
for (i=[0:10:50])
translate ([i,i,0]) cube (15);
}
gives the union of those objects.
Roger.
On 30 March 2018 at 16:08, jamcultur nyponen@gmail.com wrote:
nophead wrote
children() doesn't work with objects generated in a for loop
Well yes and no. A for loop produces a union of all its iterations, so
only
produces one child. I think modules do the same. Nothing can return
multiple children, you can only pass them explicitly as a list.
But for this case it would work to decouple part1 and part 2.
part1.scad___________
module part1() {
echo("part1");
children();
}
part2.scad___________
module part2() {
echo("part2");
}
part_test.scad_________
use
<part1.scad>
use
<part2.scad>
part1() part2();
I haven't tested this yet to see if it will work with my code that
generates
objects in a loop, but I will. Thanks.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
** Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 **
-- BitWizard writes Linux device drivers for any device you may have! --
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.