cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

# Polygon with variable number of sides

Anonymous
Not applicable
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

5 REPLIES 5
Moderator
Jevrod wrote:
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

You won't be able to put a for/next loop in a PGON command.
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
Moderator
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:

Cheers,
Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.9, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
yeah, thanks for the PUT GET command, it's exactly what i need
Anonymous
Not applicable
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.
Anonymous
Not applicable
Karl wrote:
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
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