<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Random size object in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Random-size-object/m-p/398234#M5622</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to create a rectangle whose size would be random each time it is placed or a parameter is changed.&lt;/P&gt;
&lt;P&gt;I've based the rectangle on a graphisoft object I found &lt;A href="https://gdl.graphisoft.com/gdl-basics/hotspots-graphical-editing" target="_self"&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a rectangle of height A and width B, where A = B.&lt;BR /&gt;The object is coded so that point 0,0 is in the middle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A dynamic hotspot to manage the A value is located at coordinates 0,A/2.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;With the RND() command, I manage to create squares of random size, but I have two problems:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;The dynamic hotspot is no longer located on the rectangle, even though it should be there by definition.&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;The A value displayed by archicad does not correspond to the drawn A value.&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me? Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2023-09-14 à 14.17.04.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/45759iACFE3097538CA223/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2023-09-14 à 14.17.04.png" alt="Capture d’écran 2023-09-14 à 14.17.04.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;!MASTER SCRIPT
aleatoire_scale = RND(0.4)
temp_scale = A* (0.8+aleatoire_scale)
A=temp_scale
B=temp_scale
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;!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&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;! 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
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Sep 2024 11:50:16 GMT</pubDate>
    <dc:creator>Mathias Jonathan</dc:creator>
    <dc:date>2024-09-26T11:50:16Z</dc:date>
    <item>
      <title>Random size object</title>
      <link>https://community.graphisoft.com/t5/GDL/Random-size-object/m-p/398234#M5622</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to create a rectangle whose size would be random each time it is placed or a parameter is changed.&lt;/P&gt;
&lt;P&gt;I've based the rectangle on a graphisoft object I found &lt;A href="https://gdl.graphisoft.com/gdl-basics/hotspots-graphical-editing" target="_self"&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a rectangle of height A and width B, where A = B.&lt;BR /&gt;The object is coded so that point 0,0 is in the middle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A dynamic hotspot to manage the A value is located at coordinates 0,A/2.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;With the RND() command, I manage to create squares of random size, but I have two problems:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;The dynamic hotspot is no longer located on the rectangle, even though it should be there by definition.&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;The A value displayed by archicad does not correspond to the drawn A value.&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me? Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2023-09-14 à 14.17.04.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/45759iACFE3097538CA223/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2023-09-14 à 14.17.04.png" alt="Capture d’écran 2023-09-14 à 14.17.04.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;!MASTER SCRIPT
aleatoire_scale = RND(0.4)
temp_scale = A* (0.8+aleatoire_scale)
A=temp_scale
B=temp_scale
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;!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&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;! 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
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 11:50:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Random-size-object/m-p/398234#M5622</guid>
      <dc:creator>Mathias Jonathan</dc:creator>
      <dc:date>2024-09-26T11:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Random size object</title>
      <link>https://community.graphisoft.com/t5/GDL/Random-size-object/m-p/398265#M5623</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/6242"&gt;@Mathias Jonathan&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;For your Master script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;!MASTER SCRIPT

aleatoire_scale = RND(0.4)
temp_scale = A*(0.8+aleatoire_scale)

A=temp_scale
B=temp_scale
halfA = A/2&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for your Parameter script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;! PARAMETERS SCRIPT

PARAMETERS A = A
PARAMETERS B = B
PARAMETERS halfA = halfA

lock "B"
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 16:19:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Random-size-object/m-p/398265#M5623</guid>
      <dc:creator>MetalFingerz</dc:creator>
      <dc:date>2023-09-14T16:19:26Z</dc:date>
    </item>
  </channel>
</rss>

