Hi, I'm a newbie and have just started exploring openScad. For some reason
whenever I try to create a module function, it returns a 'No top level
geometry to render' error. I've tried it multiple times and it always
results in this error. I'm clueless now. An example code and a screenshot of
the error are below.
radius=16;
sides=5;
thickness=1.5;
module polyshape(){
difference(){
//outside part
offset(r=5,$fn=48)
circle(r=radius, $fn=sides);
//inside part which is being subtracted
offset(r=5-thickness,$fn=48)
circle(r=radius, $fn=sides);}
}
http://forum.openscad.org/file/n15744/Screen_Shot_2016-01-17_at_10.png
Thanks in advance!
--
View this message in context: http://forum.openscad.org/module-function-not-working-tp15744.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
This is pretty common for non-programmers.
The deal is you have created the module but you never invoke it.
you need to add the line:
polyshape();
in the main part of the program..I typically place it at the top
Darren
On Jan 17, 2016, at 7:56 PM, jjnat14 jjnat86@outlook.com wrote:
Hi, I'm a newbie and have just started exploring openScad. For some reason
whenever I try to create a module function, it returns a 'No top level
geometry to render' error. I've tried it multiple times and it always
results in this error. I'm clueless now. An example code and a screenshot of
the error are below.
radius=16;
sides=5;
thickness=1.5;
module polyshape(){
difference(){
//outside part
offset(r=5,$fn=48)
circle(r=radius, $fn=sides);
//inside part which is being subtracted
offset(r=5-thickness,$fn=48)
circle(r=radius, $fn=sides);}
}
http://forum.openscad.org/file/n15744/Screen_Shot_2016-01-17_at_10.png
Thanks in advance!
--
View this message in context: http://forum.openscad.org/module-function-not-working-tp15744.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
A module is like a function definition: it defines a named "function" which
takes arguments, and returns geometry as a result. It doesn't "do" anything
by itself.
If you don't call the module, then no geometry is generated.
Add the following code to the end of your script, which calls the module:
polyshape();
On 17 January 2016 at 22:56, jjnat14 jjnat86@outlook.com wrote:
Hi, I'm a newbie and have just started exploring openScad. For some reason
whenever I try to create a module function, it returns a 'No top level
geometry to render' error. I've tried it multiple times and it always
results in this error. I'm clueless now. An example code and a screenshot
of
the error are below.
radius=16;
sides=5;
thickness=1.5;
module polyshape(){
difference(){
//outside part
offset(r=5,$fn=48)
circle(r=radius, $fn=sides);
//inside part which is being subtracted
offset(r=5-thickness,$fn=48)
circle(r=radius, $fn=sides);}
}
http://forum.openscad.org/file/n15744/Screen_Shot_2016-01-17_at_10.png
Thanks in advance!
--
View this message in context:
http://forum.openscad.org/module-function-not-working-tp15744.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thank you
--
View this message in context: http://forum.openscad.org/module-function-not-working-tp15744p15748.html
Sent from the OpenSCAD mailing list archive at Nabble.com.