discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Why doesn't this use statement work?

J
jamcultur
Tue, Mar 27, 2018 8:46 PM

As I mentioned in another thread, I have a long complicated piece of OpenSCAD
code that I am trying to
simplify so that I can enhance it, but I haven't found a way that works yet.
My latest attempt to modularize the code failed, and I don't understand why.
Here's a simplified example with three .scad files.

part1.scad___________

module part1() {
echo("part1");
part2();
}


part2.scad___________

module part2() {
echo("part2");
}


part_test.scad_________

use <part1.scad>
use <part2.scad>

part1();


When I try to preview or render part_test.scad, I get the message, "WARNING:
Ignoring unknown module 'part2', even though there is a  "use <part2.scad>"
statement in the file, and part2.scad is in the same directory. If I move
the "use <part2.scad>" statement from part_test.scad, to part1.scad, it
works, but that structure would not allow me to modularize my code in a
useful way. Is there a way to make this work?

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

As I mentioned in another thread, I have a long complicated piece of OpenSCAD code that I am trying to simplify so that I can enhance it, but I haven't found a way that works yet. My latest attempt to modularize the code failed, and I don't understand why. Here's a simplified example with three .scad files. part1.scad___________ module part1() { echo("part1"); part2(); } ____________________ part2.scad___________ module part2() { echo("part2"); } ____________________ part_test.scad_________ use <part1.scad> use <part2.scad> part1(); ____________________ When I try to preview or render part_test.scad, I get the message, "WARNING: Ignoring unknown module 'part2', even though there is a "use <part2.scad>" statement in the file, and part2.scad is in the same directory. If I move the "use <part2.scad>" statement from part_test.scad, to part1.scad, it works, but that structure would not allow me to modularize my code in a useful way. Is there a way to make this work? -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Tue, Mar 27, 2018 8:59 PM

part2() is defined only after the compilation of part1.scad. Reverse the
use's order in part_test.scad.

Em ter, 27 de mar de 2018 21:46, jamcultur nyponen@gmail.com escreveu:

As I mentioned in another thread, I have a long complicated piece of
OpenSCAD
code that I am trying to
simplify so that I can enhance it, but I haven't found a way that works
yet.
My latest attempt to modularize the code failed, and I don't understand
why.
Here's a simplified example with three .scad files.

part1.scad___________

module part1() {
echo("part1");
part2();
}


part2.scad___________

module part2() {
echo("part2");
}


part_test.scad_________

use <part1.scad>
use <part2.scad>

part1();


When I try to preview or render part_test.scad, I get the message,
"WARNING:
Ignoring unknown module 'part2', even though there is a  "use <part2.scad>"
statement in the file, and part2.scad is in the same directory. If I move
the "use <part2.scad>" statement from part_test.scad, to part1.scad, it
works, but that structure would not allow me to modularize my code in a
useful way. Is there a way to make this work?

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


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

part2() is defined only after the compilation of part1.scad. Reverse the use's order in part_test.scad. Em ter, 27 de mar de 2018 21:46, jamcultur <nyponen@gmail.com> escreveu: > As I mentioned in another thread, I have a long complicated piece of > OpenSCAD > code that I am trying to > simplify so that I can enhance it, but I haven't found a way that works > yet. > My latest attempt to modularize the code failed, and I don't understand > why. > Here's a simplified example with three .scad files. > > part1.scad___________ > > module part1() { > echo("part1"); > part2(); > } > ____________________ > > > part2.scad___________ > > module part2() { > echo("part2"); > } > ____________________ > > > part_test.scad_________ > > use <part1.scad> > use <part2.scad> > > part1(); > ____________________ > > When I try to preview or render part_test.scad, I get the message, > "WARNING: > Ignoring unknown module 'part2', even though there is a "use <part2.scad>" > statement in the file, and part2.scad is in the same directory. If I move > the "use <part2.scad>" statement from part_test.scad, to part1.scad, it > works, but that structure would not allow me to modularize my code in a > useful way. Is there a way to make this work? > > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Tue, Mar 27, 2018 9:09 PM

I don't think that will work.

part1.scad uses part2, so it must use part2.scad.

part_test.scad only needs to use part1.scad.

On 27 March 2018 at 21:59, Ronaldo Persiano rcmpersiano@gmail.com wrote:

part2() is defined only after the compilation of part1.scad. Reverse the
use's order in part_test.scad.

Em ter, 27 de mar de 2018 21:46, jamcultur nyponen@gmail.com escreveu:

As I mentioned in another thread, I have a long complicated piece of
OpenSCAD
code that I am trying to
simplify so that I can enhance it, but I haven't found a way that works
yet.
My latest attempt to modularize the code failed, and I don't understand
why.
Here's a simplified example with three .scad files.

part1.scad___________

module part1() {
echo("part1");
part2();
}


part2.scad___________

module part2() {
echo("part2");
}


part_test.scad_________

use <part1.scad>
use <part2.scad>

part1();


When I try to preview or render part_test.scad, I get the message,
"WARNING:
Ignoring unknown module 'part2', even though there is a  "use
<part2.scad>"
statement in the file, and part2.scad is in the same directory. If I move
the "use <part2.scad>" statement from part_test.scad, to part1.scad, it
works, but that structure would not allow me to modularize my code in a
useful way. Is there a way to make this work?

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


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

I don't think that will work. part1.scad uses part2, so it must use part2.scad. part_test.scad only needs to use part1.scad. On 27 March 2018 at 21:59, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > part2() is defined only after the compilation of part1.scad. Reverse the > use's order in part_test.scad. > > Em ter, 27 de mar de 2018 21:46, jamcultur <nyponen@gmail.com> escreveu: > >> As I mentioned in another thread, I have a long complicated piece of >> OpenSCAD >> code that I am trying to >> simplify so that I can enhance it, but I haven't found a way that works >> yet. >> My latest attempt to modularize the code failed, and I don't understand >> why. >> Here's a simplified example with three .scad files. >> >> part1.scad___________ >> >> module part1() { >> echo("part1"); >> part2(); >> } >> ____________________ >> >> >> part2.scad___________ >> >> module part2() { >> echo("part2"); >> } >> ____________________ >> >> >> part_test.scad_________ >> >> use <part1.scad> >> use <part2.scad> >> >> part1(); >> ____________________ >> >> When I try to preview or render part_test.scad, I get the message, >> "WARNING: >> Ignoring unknown module 'part2', even though there is a "use >> <part2.scad>" >> statement in the file, and part2.scad is in the same directory. If I move >> the "use <part2.scad>" statement from part_test.scad, to part1.scad, it >> works, but that structure would not allow me to modularize my code in a >> useful way. Is there a way to make this work? >> >> >> >> >> >> -- >> 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 > >
J
jamcultur
Tue, Mar 27, 2018 9:13 PM

Ronaldo wrote

part2() is defined only after the compilation of part1.scad. Reverse the
use's order in part_test.scad.

I tried that, and it didn't work. I still get the message WARNING: Ignoring
unknown module 'part2'.

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

Ronaldo wrote > part2() is defined only after the compilation of part1.scad. Reverse the > use's order in part_test.scad. I tried that, and it didn't work. I still get the message WARNING: Ignoring unknown module 'part2'. -- Sent from: http://forum.openscad.org/
HJ
Hugo Jackson
Tue, Mar 27, 2018 9:49 PM

I think your error message is not from “part_test.scad” but from part1.scad which can’t find part2.
If you add

use <part2.scad> to part.scad like this:

part1.scad _________

use <part2.scad>

module part1() {
echo(“part1”);
part2();
}

It should work fine.

On Mar 27, 2018, at 1:46 PM, jamcultur nyponen@gmail.com wrote:

As I mentioned in another thread, I have a long complicated piece of OpenSCAD
code that I am trying to
simplify so that I can enhance it, but I haven't found a way that works yet.
My latest attempt to modularize the code failed, and I don't understand why.
Here's a simplified example with three .scad files.

part1.scad___________

module part1() {
echo("part1");
part2();
}


part2.scad___________

module part2() {
echo("part2");
}


part_test.scad_________

use <part1.scad>
use <part2.scad>

part1();


When I try to preview or render part_test.scad, I get the message, "WARNING:
Ignoring unknown module 'part2', even though there is a  "use <part2.scad>"
statement in the file, and part2.scad is in the same directory. If I move
the "use <part2.scad>" statement from part_test.scad, to part1.scad, it
works, but that structure would not allow me to modularize my code in a
useful way. Is there a way to make this work?

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


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

I think your error message is not from “part_test.scad” but from part1.scad which can’t find part2. If you add use <part2.scad> to part.scad like this: part1.scad _________ use <part2.scad> module part1() { echo(“part1”); part2(); } It should work fine. > On Mar 27, 2018, at 1:46 PM, jamcultur <nyponen@gmail.com> wrote: > > As I mentioned in another thread, I have a long complicated piece of OpenSCAD > code that I am trying to > simplify so that I can enhance it, but I haven't found a way that works yet. > My latest attempt to modularize the code failed, and I don't understand why. > Here's a simplified example with three .scad files. > > part1.scad___________ > > module part1() { > echo("part1"); > part2(); > } > ____________________ > > > part2.scad___________ > > module part2() { > echo("part2"); > } > ____________________ > > > part_test.scad_________ > > use <part1.scad> > use <part2.scad> > > part1(); > ____________________ > > When I try to preview or render part_test.scad, I get the message, "WARNING: > Ignoring unknown module 'part2', even though there is a "use <part2.scad>" > statement in the file, and part2.scad is in the same directory. If I move > the "use <part2.scad>" statement from part_test.scad, to part1.scad, it > works, but that structure would not allow me to modularize my code in a > useful way. Is there a way to make this work? > > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
HJ
Hugo Jackson
Tue, Mar 27, 2018 9:50 PM

sorry… duh… I see thats you know that.

On Mar 27, 2018, at 2:13 PM, jamcultur nyponen@gmail.com wrote:

Ronaldo wrote

part2() is defined only after the compilation of part1.scad. Reverse the
use's order in part_test.scad.

I tried that, and it didn't work. I still get the message WARNING: Ignoring
unknown module 'part2'.

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


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

sorry… duh… I see thats you know that. > On Mar 27, 2018, at 2:13 PM, jamcultur <nyponen@gmail.com> wrote: > > Ronaldo wrote >> part2() is defined only after the compilation of part1.scad. Reverse the >> use's order in part_test.scad. > > I tried that, and it didn't work. I still get the message WARNING: Ignoring > unknown module 'part2'. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JB
Jordan Brown
Tue, Mar 27, 2018 10:16 PM

On 3/27/2018 1:46 PM, jamcultur wrote:

If I move the "use <part2.scad>" statement from part_test.scad, to part1.scad, it works, but that structure would not allow me to modularize my code in a useful way.

Actually, it's requiring you to modularize your program.

The main program invokes only part1.  It doesn't know about part2.  It
is only part1 that knows that it needs part2, so it is the one that
needs the "use".

On 3/27/2018 1:46 PM, jamcultur wrote: > If I move the "use <part2.scad>" statement from part_test.scad, to part1.scad, it works, but that structure would not allow me to modularize my code in a useful way. Actually, it's *requiring* you to modularize your program. The main program invokes only part1.  It doesn't know about part2.  It is only part1 that knows that it needs part2, so it is the one that needs the "use".
J
jamcultur
Tue, Mar 27, 2018 11:35 PM

JordanBrown wrote

On 3/27/2018 1:46 PM, jamcultur wrote:

If I move the "use

<part2.scad>
" statement from part_test.scad, to part1.scad, it works, but that
structure would not allow me to modularize my code in a useful way.

Actually, it's requiring you to modularize your program.

The main program invokes only part1.  It doesn't know about part2.  It
is only part1 that knows that it needs part2, so it is the one that
needs the "use".

I need part1 and part2 to be independent modules without any information
about each other. That is so that I can code different versions of part_test
that use different versions of part1 and part2. I want any version of part1
to work with any version of part2. That won't work if put the use for a
particular version of part2 in part1.

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

JordanBrown wrote > On 3/27/2018 1:46 PM, jamcultur wrote: >> If I move the "use > <part2.scad> > " statement from part_test.scad, to part1.scad, it works, but that > structure would not allow me to modularize my code in a useful way. > > Actually, it's *requiring* you to modularize your program. > > The main program invokes only part1.  It doesn't know about part2.  It > is only part1 that knows that it needs part2, so it is the one that > needs the "use". I need part1 and part2 to be independent modules without any information about each other. That is so that I can code different versions of part_test that use different versions of part1 and part2. I want any version of part1 to work with any version of part2. That won't work if put the use for a particular version of part2 in part1. -- Sent from: http://forum.openscad.org/
DM
doug moen
Wed, Mar 28, 2018 12:10 AM

Then I guess you need include instead of use.

On 27 March 2018 at 19:35, jamcultur nyponen@gmail.com wrote:

JordanBrown wrote

On 3/27/2018 1:46 PM, jamcultur wrote:

If I move the "use

<part2.scad>
" statement from part_test.scad, to part1.scad, it works, but that
structure would not allow me to modularize my code in a useful way.

Actually, it's requiring you to modularize your program.

The main program invokes only part1.  It doesn't know about part2.  It
is only part1 that knows that it needs part2, so it is the one that
needs the "use".

I need part1 and part2 to be independent modules without any information
about each other. That is so that I can code different versions of
part_test
that use different versions of part1 and part2. I want any version of part1
to work with any version of part2. That won't work if put the use for a
particular version of part2 in part1.

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


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

Then I guess you need `include` instead of `use`. On 27 March 2018 at 19:35, jamcultur <nyponen@gmail.com> wrote: > JordanBrown wrote > > On 3/27/2018 1:46 PM, jamcultur wrote: > >> If I move the "use > > <part2.scad> > > " statement from part_test.scad, to part1.scad, it works, but that > > structure would not allow me to modularize my code in a useful way. > > > > Actually, it's *requiring* you to modularize your program. > > > > The main program invokes only part1. It doesn't know about part2. It > > is only part1 that knows that it needs part2, so it is the one that > > needs the "use". > > I need part1 and part2 to be independent modules without any information > about each other. That is so that I can code different versions of > part_test > that use different versions of part1 and part2. I want any version of part1 > to work with any version of part2. That won't work if put the use for a > particular version of part2 in part1. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Wed, Mar 28, 2018 9:33 AM

Or pass part2 to part1 as a child.

On 28 March 2018 at 01:10, doug moen doug@moens.org wrote:

Then I guess you need include instead of use.

On 27 March 2018 at 19:35, jamcultur nyponen@gmail.com wrote:

JordanBrown wrote

On 3/27/2018 1:46 PM, jamcultur wrote:

If I move the "use

<part2.scad>
" statement from part_test.scad, to part1.scad, it works, but that
structure would not allow me to modularize my code in a useful way.

Actually, it's requiring you to modularize your program.

The main program invokes only part1.  It doesn't know about part2.  It
is only part1 that knows that it needs part2, so it is the one that
needs the "use".

I need part1 and part2 to be independent modules without any information
about each other. That is so that I can code different versions of
part_test
that use different versions of part1 and part2. I want any version of
part1
to work with any version of part2. That won't work if put the use for a
particular version of part2 in part1.

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


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

Or pass part2 to part1 as a child. On 28 March 2018 at 01:10, doug moen <doug@moens.org> wrote: > Then I guess you need `include` instead of `use`. > > On 27 March 2018 at 19:35, jamcultur <nyponen@gmail.com> wrote: > >> JordanBrown wrote >> > On 3/27/2018 1:46 PM, jamcultur wrote: >> >> If I move the "use >> > <part2.scad> >> > " statement from part_test.scad, to part1.scad, it works, but that >> > structure would not allow me to modularize my code in a useful way. >> > >> > Actually, it's *requiring* you to modularize your program. >> > >> > The main program invokes only part1. It doesn't know about part2. It >> > is only part1 that knows that it needs part2, so it is the one that >> > needs the "use". >> >> I need part1 and part2 to be independent modules without any information >> about each other. That is so that I can code different versions of >> part_test >> that use different versions of part1 and part2. I want any version of >> part1 >> to work with any version of part2. That won't work if put the use for a >> particular version of part2 in part1. >> >> >> >> -- >> 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 > >