Polygon with variable number of sides
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-28 02:05 AM
2009-01-28
02:05 AM
is it possible to create a polygon with a variable number of sides ?
something like this ?
PGON nSide, 0, -1,
for i to nSide
i,
next i
where nSide is the variable for the number of side
and i, the numerotation of EDGE, incremented at each loop
i made it for VERT and EDGE, but impossible to realise with polygon
if anyone got the answer.....
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-28 04:00 AM
2009-01-28
04:00 AM
Jevrod wrote:You won't be able to put a for/next loop in a PGON command.
hello
is it possible to create a polygon with a variable number of sides ?
something like this ?
PGON nSide, 0, -1,
for i to nSide
i,
next i
where nSide is the variable for the number of side
and i, the numerotation of EDGE, incremented at each loop
i made it for VERT and EDGE, but impossible to realise with polygon
if anyone got the answer.....
But if you only had a limited number of sides required you could say ...
IF nSide = 3 then
PGON 3, vect, status, edge1, edge2, ... edgen
ENDIF
IF nSide = 4 then
PGON 4, vect, status, edge1, edge2, ... edgen
ENDIF
IF nSide = 5 then
PGON 5, vect, status, edge1, edge2, ... edgen
ENDIF
.... etc.
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-28 06:12 AM
2009-01-28
06:12 AM
If the computation of the points lends itself to iteration (presumably the reason you shows a for-loop), then I think that you can assemble the points into the parameter buffer in your loop by outputting them to the buffer with PUT and then use a GET (or USE) with the PGON to retrieve the computed values.
David Nicholson-Cole gives many examples of PUT/GET combinations in the GDL Cookbook. See:
http://archicad-talk.graphisoft.com/viewtopic.php?t=23839
Cheers,
Karl
David Nicholson-Cole gives many examples of PUT/GET combinations in the GDL Cookbook. See:
Cheers,
Karl
AC 28 USA and earlier • macOS Sequoia 15.4, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-28 07:40 PM
2009-01-28
07:40 PM
yeah, thanks for the PUT GET command, it's exactly what i need
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-01-28 09:42 PM
2009-01-28
09:42 PM
Of course, you can write pgons under this form
if bCond1 then
put 6, 0, 16, 1, 2, 3, 4, 5, 6 ! # 1
put 6, 0, 16, 7, 8, 9, 10, 11, 12 ! # 2
else
put 8, 0, 16, 1, 2, 3, 4, 5, 6, 7, 8 ! # 1
put 8, 0, 16, 9, 10, 11, 12, 13, 14, 15, 16 ! # 2
endif
for k = 1 to 2
pgon get(nsp/(3-k))
next k
But ... since you HAVE to declare each pgon, it is easier to write them directly.
I don't think put/get statements are of any help for pgons, in general.
It would be difficult to deal with buffer polycount.
Barry's solution seems more relevant.
if bCond1 then
pgon 6, 0, 16, 1, 2, 3, 4, 5, 6 ! # 1
pgon 6, 0, 16, 7, 8, 9, 10, 11, 12 ! # 2
else
pgon 8, 0, 16, 1, 2, 3, 4, 5, 6, 7, 8 ! # 1
pgon 8, 0, 16, 9, 10, 11, 12, 13, 14, 15, 16 ! # 2
endif
For a single planar pgon with a variable number of sides, put/get statements can work.
There are more simple ways to achieve this.
Use primitives only when not any current tool can achieve what you want.
if bCond1 then
put 6, 0, 16, 1, 2, 3, 4, 5, 6 ! # 1
put 6, 0, 16, 7, 8, 9, 10, 11, 12 ! # 2
else
put 8, 0, 16, 1, 2, 3, 4, 5, 6, 7, 8 ! # 1
put 8, 0, 16, 9, 10, 11, 12, 13, 14, 15, 16 ! # 2
endif
for k = 1 to 2
pgon get(nsp/(3-k))
next k
But ... since you HAVE to declare each pgon, it is easier to write them directly.
I don't think put/get statements are of any help for pgons, in general.
It would be difficult to deal with buffer polycount.
Barry's solution seems more relevant.
if bCond1 then
pgon 6, 0, 16, 1, 2, 3, 4, 5, 6 ! # 1
pgon 6, 0, 16, 7, 8, 9, 10, 11, 12 ! # 2
else
pgon 8, 0, 16, 1, 2, 3, 4, 5, 6, 7, 8 ! # 1
pgon 8, 0, 16, 9, 10, 11, 12, 13, 14, 15, 16 ! # 2
endif
For a single planar pgon with a variable number of sides, put/get statements can work.
There are more simple ways to achieve this.
Use primitives only when not any current tool can achieve what you want.
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2009-02-07 02:16 AM
2009-02-07
02:16 AM
Karl wrote:I did that, using put get, worked for me. I was making coon object so the script was bit complicated, but, eventually got it assembled for up to 9x9 point coon, using two loops to calculate values and then 4 loops to assign them in proper order
If the computation of the points lends itself to iteration (presumably the reason you shows a for-loop), then I think that you can assemble the points into the parameter buffer in your loop by outputting them to the buffer with PUT and then use a GET (or USE) with the PGON to retrieve the computed values.
Cheers,
Karl