Welcome! Log In Create A New Profile

Advanced

OpenSCAD Help

Posted by indieflow 
OpenSCAD Help
December 28, 2011 08:35AM
Hi guys,

I'm pretty new to the world of RepRap and literally just venturing into 3D designs. I'm currently playing around with OpenSCAD, which seems pretty easy for simple designs (with use of the online instructions), though when venturing into the more complex side of things, safe to say I get a bit lost! confused smiley

After browsing the internet extensively I've not managed to find any good forums to post OpenSCAD questions on, so I thought here would be a good place to try!


[indieflows.blogspot.com]
[www.emakershop.com]
Re: OpenSCAD Help
December 28, 2011 08:36AM
I've been trying to make a polyhedron, though can anyone explain why I can compile (F5) the code below (looks all good, no pink triangles!), though when I try and render (F6), I get the warning: No top level geometry to render? Have I missed something?

polyhedron
(points=[
[-7.5,0,-3],[-5,0,-3],[5,0,-3],[7.5,0,-3],[0,0,7],[1,0,10],[-1,0,10],
[-7.5,2,-3],[-5,2,-3],[5,2,-3],[7.5,2,-3],[0,2,7],[1,2,10],[-1,2,10]
], 
triangles=[
[6,1,0],[4,1,0],[6,5,0],[0,6,4],[5,3,2],[4,3,2],[3,6,5],[3,4,5],[6,5,4],
[7,8,13],[7,8,11],[7,12,13],[11,13,7],[9,10,12],[9,10,11],[12,13,10],[12,11,10],[11,12,13],
[5,10,3],[5,12,10],[7,6,0],[13,6,7],[4,8,1],[11,8,4],[9,4,2],[9,11,4],
[5,6,13],[13,12,5],[0,1,7],[1,8,7],[2,3,9],[3,10,9]
]
);

Thanks for any help smiling bouncing smiley


[indieflows.blogspot.com]
[www.emakershop.com]
Re: OpenSCAD Help
December 28, 2011 08:54AM
If you go to the openscad.org web site, there is a mailing list which is where most of the discussion happens.

David
Re: OpenSCAD Help
December 28, 2011 08:54AM
It compiles, but CGAL complains about an illegal polygonal object. There seem to be a lot of extra triangles on the front and back faces, try getting rid of those.

EDIT]

Yup, that seems to work.

polyhedron
(points=[
[-7.5,0,-3],[-5,0,-3],[5,0,-3],[7.5,0,-3],[0,0,7],[1,0,10],[-1,0,10],
[-7.5,2,-3],[-5,2,-3],[5,2,-3],[7.5,2,-3],[0,2,7],[1,2,10],[-1,2,10]
], 
triangles=[
[4,1,0],[0,6,4],[4,3,2],[3,4,5],[6,5,4],
[7,8,11],[11,13,7],[9,10,11],[12,11,10],[11,12,13],
[5,10,3],[5,12,10],[7,6,0],[13,6,7],[4,8,1],[11,8,4],[9,4,2],[9,11,4],
[5,6,13],[13,12,5],[0,1,7],[1,8,7],[2,3,9],[3,10,9]
]
);

Edited 1 time(s). Last edit at 12/28/2011 08:59AM by Andrew Smith.
Re: OpenSCAD Help
December 28, 2011 10:08AM
davidgoodenough Wrote:
-------------------------------------------------------
> If you go to the openscad.org web site, there is a
> mailing list which is where most of the discussion
> happens.
>
> David

Ah right, thanks David thumbs up
Re: OpenSCAD Help
December 28, 2011 10:11AM
Andrew Smith Wrote:
-------------------------------------------------------
> It compiles, but CGAL complains about an illegal
> polygonal object. There seem to be a lot of extra
> triangles on the front and back faces, try getting
> rid of those.
>
> EDIT]
>
> Yup, that seems to work.
>

Wow, thanks Andrew thumbs up So just to confirm, as I'm crap at figuring out how to fill a space with the minimum amount of triangles, the computer doesn't like it? lol Or is it that you can't have over lapping triangles on a face?
Re: OpenSCAD Help
December 28, 2011 10:49AM
You need to produce a simple, manifold, hull. No more than two faces can share the same line. No holes. No overlapping polygons.
Re: OpenSCAD Help
December 28, 2011 10:50AM
The message is "ERROR: Illegal polygonal object - make sure all polygons are defined with the same winding order. Skipping affected object.".

The issue with triangle meshes is the computer doesn't know what side of it is supposed to be the inside, and it bases the calculations (at least that's my guess/understanding) on the so called winding order.

If you define the corners of a trignale like this (with A being the first point, and so on):

AB
C

And another next to it (or on top of it which might be the case in your example), like this:

AC
B

The normals would be the opposite direction, and Openscad is unable to calculate if it's supposed to be the inside or the outside of the object.

Also, openscad doesn't like overlapping faces very much, so the problem could come from that as well, yes.


On an unrelated note, and not saying it's not an excellent exercise to hand code a mesh from time to time; this is how I'd make your object, which may be totally useless depending on what you were going to achieve. winking smiley

p1 = 5;
p2 = 10;
t = 3;
rotate([90,0,0]) linear_extrude(height=2) polygon([[0,0],[p1,-p2],[p1+t,-p2],[t/2,t],[-t/2,t],[-p1-t,-p2],[-p1,-p2]]);


--
-Nudel
Blog with RepRap Comic
Re: OpenSCAD Help
December 28, 2011 12:42PM
Right, I think I get it now! Though have to say Nudel, that code you wrote is well above my level at the moment! lol Thanks for it though! Is there any documentation I can read to learn how you worked that out?


[indieflows.blogspot.com]
[www.emakershop.com]
Re: OpenSCAD Help
December 28, 2011 06:48PM
You're welcome smiling smiley

I learned the linear extrude and polygon in the documentation here: [en.wikibooks.org]

And here's the rest of the manual: [en.wikibooks.org]

The code I wrote is less complicated than yours actually, mine just uses a few variables to make it somewhat parametric. I absolutely love openscad, I'm no expert at it, but it should be added I've used POV-Ray for 10+ years, so I'm used to the concept. winking smiley


--
-Nudel
Blog with RepRap Comic
Re: OpenSCAD Help
December 31, 2011 05:03AM
Not sure if this might help, but it looks quite useful and is quite easy to use.

[github.com]

Geoff
Sorry, only registered users may post in this forum.

Click here to login