cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
GDL
About building parametric objects with GDL.

Draw a polygon in the user interface?

Kaj_AL
Enthusiast

Hello!

Is there anyway I can draw a polygon in the user interface? I have a slab accessory, and it would be great if I could draw the slab in the user interface using a simple polygon or line.

 

If this is not possible, are there any good ideas for workarounds? Using multiple lines, dots, perhaps multiples O's in a line?

 

Thank you!

/Kaj

 

Operating system used: Windows 11

Archicad 24-27 SWE
Dell Precision 5560, Windows 11 Pro
11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz 2.61 GHz
7 REPLIES 7
Barry Kelly
Moderator

Straight lines and rectangles only unfortunately as far as I know.

I don't think you can even draw an angled line.

 

The best you could do is to add a picture with a transparent background (alpha channel) maybe?

 

But if you want a live image of your slab, I don't think that is possible.

 

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
Kaj_AL
Enthusiast

I started fiddling with it, but if anyone see this and have better ideas or an idea on how to simplify the code, feel free to chime in! Any help is appreciated.

 

I also have issues with it not being rotated correctly (to the north), as well as the number furthest to the right (here number 4) disappear.

 

Kaj_AL_0-1720187689338.png

 

 

!MAP
MapZeroX=300
MapZeroY=80
!Max mapsize: 200x170

LowX=0
HighX=0
LowY=0
HighY=0

!Find the highest and lowest X and Y points of the slab
FOR i=1 TO antal_nodes
IF ac_coords[i][2]>HighX THEN HighX=ac_coords[i][2]
IF ac_coords[i][3]>HighY THEN HighY=ac_coords[i][3]
IF ac_coords[i][2]<LowX THEN LowX=ac_coords[i][2]
IF ac_coords[i][3]<LowY THEN LowY=ac_coords[i][3]
NEXT i

!Make sure they fit on the interface. The ReSizer is a number to scale the drawing.
SlabSizeX=HighX-LowX
SlabSizeY=HighY-LowY
IF SlabsizeX/SlabSizeY>200/170 THEN ReSizer=SlabsizeX/200 ELSE ReSizer=SlabsizeY/170

DIM SlabMapX[]
DIM SlabMapY[]
DIM SlabHypoLength[]
DIM NumSlabHypoNodes[]
DotDistance=25 !Distance between dots on the interface.

!Translate slab polygon coordinates to interface coordinates
FOR i=1 TO antal_nodes
SlabMapX[i]=(ac_coords[i][2]/Resizer+MapZeroX-LowX/Resizer)
SlabMapY[i]=(ac_coords[i][3]/Resizer+MapZeroY-LowY/Resizer)
UI_SEPARATOR SlabMapX[i]-3,SlabMapY[i]-3,SlabMapX[i]+3,SlabMapY[i]+3
NEXT i

!Divide slab edges in multiple points
FOR i=1 TO antal_nodes-1
SlabHypoLength[i]=SQR((SlabMapX[i+1]-SlabMapX[i])*(SlabMapX[i+1]-SlabMapX[i])+(SlabMapY[i+1]-SlabMapY[i])*(SlabMapY[i+1]-SlabMapY[i]))
NumSlabHypoNodes[i]=ROUND_INT(SlabHypoLength[i]/Resizer/DotDistance)
IF NumSlabHypoNodes[i]<0.5 THEN NumSlabHypoNodes[i]=1 !Make sure there's at least one node in between
FOR n=1 TO NumSlabHypoNodes[i]-1
MidX=(SlabMapX[i]*(1-n/NumSlabHypoNodes[i]))+(SlabMapX[i+1]*(n/NumSlabHypoNodes[i]))
MidY=(SlabMapY[i]*(1-n/NumSlabHypoNodes[i]))+(SlabMapY[i+1]*(n/NumSlabHypoNodes[i]))
UI_SEPARATOR MidX-2,MidY-2,MidX+2,MidY+2
NEXT n
NEXT i

!Add edge number to edges
FOR i=1 TO antal_nodes-1
EdgeCenterX=SlabMapX[i]*0.5+SlabMapX[i+1]*0.5
EdgeCenterY=SlabMapY[i]*0.5+SlabMapY[i+1]*0.5
EdgeNum=STR(i,2,0)
UI_OUTFIELD EdgeNum,EdgeCenterX-6,EdgeCenterY-6
NEXT i

 

 

 

 

 

 

Archicad 24-27 SWE
Dell Precision 5560, Windows 11 Pro
11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz 2.61 GHz

Very nice!

I once saw an UI where something similar was done, but instead of tiny seperators the author had used a single pixel picture, so basically drawing non-anti-aliased lines. The upside of that approach is that colored lines are possible.

Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

@runxel wrote:

I once saw an UI where something similar was done, but instead of tiny seperators the author had used a single pixel picture, so basically drawing non-anti-aliased lines. The upside of that approach is that colored lines are possible.


I remember that.

We used to put red rectangles around buttons for changing UI pages if I remember correctly.

This was before we had the hierarchical pages.

 

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
Jochen Suehlo
Advisor

Several years ago I experimented with composite 1 pixel graphics.
There is a problem if you place a lot of single-pixel graphics. Then you can see how Archicad paints the lines in the UI bit by bit and does not deliver them completely assembled.

I discarded this approach at the time and work with straight line pixels, e.g. 100 x 1 pixel, which works well.

Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de

The only reliable thing with drawn pics is the rectangle, which I use a lot with different pic colors - it looks better that the ui_separator or groupbox

sometimes the leader lines...

The only possible advantage for me would be the overlay of something over another picture.

With the other ui elements overlay is possible with doubling the commands:

 [commands]

pictiure

[commands]

BTW:

Long time ago Olivier Dentan had experimented with such scripts with dot pics. I have just found out that I sill have them in my stash. (line, arc, arrow)

Maybe I will go back to this idea..

Ben Cohen
Advocate

This would be the top of my wish list for GDL features - a "ui_poly". For me it would save so many little png's I have created over the years. And for this sort of thing, create a much nicer UI..

 

I just released an update to my roof accessory. I found a slightly better work around for creating a polygon in the UI.

I found the 'dot' method a bit slow and un-sightly - particularly on PC

Rather than create dots that get repeated, I create a few png's, about 10px by 10px with a diagonal line across them. So I only need to place 4 or 5 per segment.. here are the results. Looks pretty neat - even when the line is not a 45 degree angle... 

4D Roofing UI.png

 

Ben Cohen
Mac and PC
Archicad (Latest Version) aus
www.4DLibrary.com.au

Setup info provided by author

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!