<?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 Re: Alternate objects dimension in loop in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/373895#M849</link>
    <description>&lt;P&gt;Could also work like that if you need more than 2 Variations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;current_sub = 1

for i=1 to last 
		gosub current_sub
next i

END:

1:
!Dimension variation
current_sub = 2
RETURN

2:
!Dimension variation
current_sub = 3
RETURN

3:
!Dimension variation
current_sub = 1
RETURN

&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>Tue, 21 Mar 2023 18:27:05 GMT</pubDate>
    <dc:creator>vdentello</dc:creator>
    <dc:date>2023-03-21T18:27:05Z</dc:date>
    <item>
      <title>Alternate objects dimension in loop</title>
      <link>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372492#M845</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I might be drowning in a glass of water here.&lt;/P&gt;
&lt;P&gt;I have a working script where two objects of the same width are duplicated by a FOR-TO-NEXT, where the user chooses if it want all the objects at the same height or alternate height.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jc4d_0-1678271689274.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/34927i3E1125CC3265B96C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jc4d_0-1678271689274.png" alt="jc4d_0-1678271689274.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jc4d_1-1678271697446.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/34928iD5CB3B9F4C55E36E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jc4d_1-1678271697446.png" alt="jc4d_1-1678271697446.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;With my limited knoledge, I have set two loops, one for the "smaller" and another one for the "bigger" one. My problem comes when changing the width of the whole repetition element where the last object in the loop is "out" from the cage and sometimes it doesn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case if I set the width of the whole element to 1550mm it looks as it should:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jc4d_2-1678271906618.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/34929i065C587DEFC72C19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jc4d_2-1678271906618.png" alt="jc4d_2-1678271906618.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if I set the width of the whole element to 1475mm it goes crazy:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jc4d_3-1678271970452.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/34930iED0D0836A9231F01/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jc4d_3-1678271970452.png" alt="jc4d_3-1678271970452.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if instead of two loops I can do the same but with one loop only.&lt;/P&gt;
&lt;P&gt;Here is my loop for each element:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;N1= INT(A /(width+gap))
FOR H=1 TO N1
GOSUB 20
ADDx gap + width
NEXT H

N2= INT(A /(width-gap))
FOR H=1 TO N2 STEP 2
GOSUB 40
ADDx gap + width
NEXT H

DEL TOP
END

20:
ADDx gap*0.5
block widthA, heightB, ZZYZX
RETURN

40:
ADDx gap + widthA + gap*0.5
block widthA, heightC, ZZYZX
RETURN

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Juan&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 10:46:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372492#M845</guid>
      <dc:creator>jc4d</dc:creator>
      <dc:date>2023-03-08T10:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate objects dimension in loop</title>
      <link>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372512#M846</link>
      <description>&lt;P&gt;Use the modulo for the current loop number. E.g.:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;for i=1 to last 
	if i%2 then
		gosub "block 1"
	else
		gosub "block 2"
	endif
next i&lt;/LI-CODE&gt;
&lt;P&gt;(where "last" is the total number fo blocks you need)&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 14:03:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372512#M846</guid>
      <dc:creator>runxel</dc:creator>
      <dc:date>2023-03-08T14:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate objects dimension in loop</title>
      <link>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372591#M847</link>
      <description>&lt;P&gt;Did not know about the&amp;nbsp;&lt;EM&gt;Modulo&amp;nbsp;&lt;/EM&gt;operation. Was thinking that you could take the integer of half your input, multiply it then compare... the same outcome in 2 characters vs 20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the blocks are just variations on the same shape, it would probably be better to use a generic subroutine and define parameters instead;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;for i=1 to last 
	if i%2 then
		height = c
	else
		height = d
	endif
	gosub "block 1"
next i&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;P&gt;Ling.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 07:26:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372591#M847</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2023-03-09T07:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate objects dimension in loop</title>
      <link>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372712#M848</link>
      <description>&lt;P&gt;Thank you both for chime in, I wasn't aware we can use a Modulo operation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both solutions are great, but the one from Ling I noticed it would be easier to maintain since there is one subroutine ony so I can ditch the second one. N&lt;SPAN&gt;evertheless&lt;/SPAN&gt;, it is great to see different&amp;nbsp; approach to the same problem. &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Juan&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 05:35:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/372712#M848</guid>
      <dc:creator>jc4d</dc:creator>
      <dc:date>2023-03-10T05:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Alternate objects dimension in loop</title>
      <link>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/373895#M849</link>
      <description>&lt;P&gt;Could also work like that if you need more than 2 Variations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;current_sub = 1

for i=1 to last 
		gosub current_sub
next i

END:

1:
!Dimension variation
current_sub = 2
RETURN

2:
!Dimension variation
current_sub = 3
RETURN

3:
!Dimension variation
current_sub = 1
RETURN

&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>Tue, 21 Mar 2023 18:27:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/Alternate-objects-dimension-in-loop/m-p/373895#M849</guid>
      <dc:creator>vdentello</dc:creator>
      <dc:date>2023-03-21T18:27:05Z</dc:date>
    </item>
  </channel>
</rss>

