We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-07-05 11:04 AM - last edited on 2024-09-24 10:10 AM by Doreena Deng
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
2024-07-05 12:13 PM
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.
2024-07-05 04:01 PM - edited 2024-07-05 04:02 PM
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.
!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
2024-07-05 10:13 PM
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.
2024-07-06 11:36 AM
@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.
2024-07-07 11:10 AM
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.
2024-07-16 02:23 PM
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..
2024-07-19 11:33 AM
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...