We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2023-09-14 02:32 PM - last edited on 2024-09-26 01:50 PM by Doreena Deng
Hello!
I'd like to create a rectangle whose size would be random each time it is placed or a parameter is changed.
I've based the rectangle on a graphisoft object I found here:
It's a rectangle of height A and width B, where A = B.
The object is coded so that point 0,0 is in the middle.
A dynamic hotspot to manage the A value is located at coordinates 0,A/2.
With the RND() command, I manage to create squares of random size, but I have two problems:
Could you help me? Thanks in advance
!MASTER SCRIPT
aleatoire_scale = RND(0.4)
temp_scale = A* (0.8+aleatoire_scale)
A=temp_scale
B=temp_scale
!2D SCRIPT
PARAMETERS A = A
PARAMETERS B = B
! initialize start ID for hotspots
_unID = 1
! --------------------------------------------------------------------------------
! non-editable hotspot (bottom edge center of square)
! --------------------------------------------------------------------------------
hotspot2 0, 0, _unID : _unID = _unID + 1
! --------------------------------------------------------------------------------
! edit size A using halfA as visual input (bottom right hotspot of rectangle)
! --------------------------------------------------------------------------------
! the tracker shows size A as reference, with custom description
hotspot2 0, 0, _unID, halfA, 1+128 !BASE (hidden)
_unID = _unID + 1
hotspot2 -1, 0, _unID, halfA, 3 !REFERENCE
_unID = _unID + 1
hotspot2 halfA, 0, _unID, halfA, 2, A, `Size A for reference` !MOVING
_unID = _unID + 1
RECT2 -A/2,-B/2,A/2,B/2
! PARAMETERS SCRIPT
PARAMETERS A = A
PARAMETERS B = B
lock "B"
! connect size "A" and "halfA" parameters
if GLOB_MODPAR_NAME = "halfA" then
A = 2 * halfA
parameters A = A
else
halfA = A / 2
parameters halfA = halfA
endif
2023-09-14 06:16 PM - edited 2023-09-14 06:19 PM
Hello @Mathias Jonathan ,
For your Master script
!MASTER SCRIPT
aleatoire_scale = RND(0.4)
temp_scale = A*(0.8+aleatoire_scale)
A=temp_scale
B=temp_scale
halfA = A/2
And for your Parameter script
! PARAMETERS SCRIPT
PARAMETERS A = A
PARAMETERS B = B
PARAMETERS halfA = halfA
lock "B"
You need to define halfA in the Master script because it is ran beforehand. When done, halfA and A are set at the same time and you do not have any discrepancy between both parameters.