discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Help with polygon() function

C
cn145912
Tue, Apr 21, 2015 11:41 AM

I wrote some code to generate a polygon, it generates these two lists

point = [[-36.6025, 136.603], [-136.603, 36.6025], [-100, -100], [36.6025,
-136.603], [136.603, -36.6025], [100, 100], [-60, 60], [-81.9615, -21.9615],
[-21.9615, -81.9615], [60, -60], [81.9615, 21.9615], [21.9615, 81.9615]]
path = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]

but for some reason, when I try

polygon(points=point, paths=path)

nothing is displayed. Could someone take a look at the lists and tell my why
they don't work?

--
View this message in context: http://forum.openscad.org/Help-with-polygon-function-tp12453.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I wrote some code to generate a polygon, it generates these two lists point = [[-36.6025, 136.603], [-136.603, 36.6025], [-100, -100], [36.6025, -136.603], [136.603, -36.6025], [100, 100], [-60, 60], [-81.9615, -21.9615], [-21.9615, -81.9615], [60, -60], [81.9615, 21.9615], [21.9615, 81.9615]] path = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11] but for some reason, when I try polygon(points=point, paths=path) nothing is displayed. Could someone take a look at the lists and tell my why they don't work? -- View this message in context: http://forum.openscad.org/Help-with-polygon-function-tp12453.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AP
Andrew Plumb
Tue, Apr 21, 2015 12:01 PM

Path is a vector-of-index-vectors, not a vector-of-indices. You need to wrap it in a second set of ‘[]’:

—snip--

point = [[-36.6025, 136.603], [-136.603, 36.6025], [-100, -100], [36.6025,
-136.603], [136.603, -36.6025], [100, 100], [-60, 60], [-81.9615, -21.9615],
[-21.9615, -81.9615], [60, -60], [81.9615, 21.9615], [21.9615, 81.9615]];
path = [[0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]];

polygon(points=point, paths=path);

—end-snip--

Andrew.

On Apr 21, 2015, at 7:41 AM, cn145912 neil.penning+openscad@gmail.com wrote:

I wrote some code to generate a polygon, it generates these two lists

point = [[-36.6025, 136.603], [-136.603, 36.6025], [-100, -100], [36.6025,
-136.603], [136.603, -36.6025], [100, 100], [-60, 60], [-81.9615, -21.9615],
[-21.9615, -81.9615], [60, -60], [81.9615, 21.9615], [21.9615, 81.9615]]
path = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]

but for some reason, when I try

polygon(points=point, paths=path)

nothing is displayed. Could someone take a look at the lists and tell my why
they don't work?

--
View this message in context: http://forum.openscad.org/Help-with-polygon-function-tp12453.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

Path is a vector-of-index-vectors, not a vector-of-indices. You need to wrap it in a second set of ‘[]’: —snip-- point = [[-36.6025, 136.603], [-136.603, 36.6025], [-100, -100], [36.6025, -136.603], [136.603, -36.6025], [100, 100], [-60, 60], [-81.9615, -21.9615], [-21.9615, -81.9615], [60, -60], [81.9615, 21.9615], [21.9615, 81.9615]]; path = [[0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]]; polygon(points=point, paths=path); —end-snip-- Andrew. > On Apr 21, 2015, at 7:41 AM, cn145912 <neil.penning+openscad@gmail.com> wrote: > > I wrote some code to generate a polygon, it generates these two lists > > point = [[-36.6025, 136.603], [-136.603, 36.6025], [-100, -100], [36.6025, > -136.603], [136.603, -36.6025], [100, 100], [-60, 60], [-81.9615, -21.9615], > [-21.9615, -81.9615], [60, -60], [81.9615, 21.9615], [21.9615, 81.9615]] > path = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11] > > but for some reason, when I try > > polygon(points=point, paths=path) > > nothing is displayed. Could someone take a look at the lists and tell my why > they don't work? > > > > -- > View this message in context: http://forum.openscad.org/Help-with-polygon-function-tp12453.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
N
nophead
Tue, Apr 21, 2015 12:07 PM

Renaming path to paths = [[ ... ]] or doing polygon(points=point,
paths=[path]); makes the code more logical.

Similarly point should be points.

--
View this message in context: http://forum.openscad.org/Help-with-polygon-function-tp12453p12455.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Renaming path to paths = [[ ... ]] or doing polygon(points=point, paths=[path]); makes the code more logical. Similarly point should be points. -- View this message in context: http://forum.openscad.org/Help-with-polygon-function-tp12453p12455.html Sent from the OpenSCAD mailing list archive at Nabble.com.