<?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: How to change parameters and keep dimensione of an objec in Libraries &amp; objects</title>
    <link>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287182#M9871</link>
    <description>The object is attached.</description>
    <pubDate>Wed, 29 Jul 2015 16:49:19 GMT</pubDate>
    <dc:creator>Durval</dc:creator>
    <dc:date>2015-07-29T16:49:19Z</dc:date>
    <item>
      <title>How to change parameters and keep dimensione of an object?</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287181#M9870</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;R&gt;This is an experimental object whose purpose is to test a code that changes parameters (by means of 'GLOB_MODPAR_NAME') in order to keep objects parts unchanged. Once resolved, I intend to apply the concept to other real life objects. &lt;BR /&gt;
 &lt;BR /&gt;
It draws two rectangles. The second rectangle is always the height of the first plus a constant 'gap'. &lt;BR /&gt;
 &lt;BR /&gt;
There is a parameter called 'method', whose value can be 1 ou 2. &lt;BR /&gt;
 &lt;BR /&gt;
If method = 1, the 'B'  parameter will be the height of first rectangle (h1=B), so the second rectangle has a height of B+gap. &lt;BR /&gt;
 &lt;BR /&gt;
If method = 2, then ' B'  should be the height of the second rectangle (h2=B), so h1=B-gap. &lt;BR /&gt;
 &lt;BR /&gt;
I don't want the heights change when method is changed. Instead, I want the 'B' is recalculated so that the heights remain the same. &lt;BR /&gt;
 &lt;BR /&gt;
For instance, method=1, so h1=B=1000 and h2=1500. When method is changed to 2, then h1 should remain =1000 and h2=1500, but B must change from 1000 to 1500. &lt;BR /&gt;
 &lt;BR /&gt;
I wrote these scripts: &lt;BR /&gt;
 
&lt;PRE&gt; 
!---- Master Script 
 
gap = 0.5 
 
IF method = 1 THEN 
	h1 = B 
	h2 = B+gap 
ELSE 
	h1 = B-gap 
	h2 = B 
ENDIF 
 
 
 
!--- Parameter Script 
 
VALUES "method" 1, 2 
 
IF GLOB_MODPAR_NAME = "method" THEN  
   IF method = 1 THEN  
      PARAMETERS B = B-gap 
   ELSE  
      PARAMETERS B = B+gap 
   ENDIF  
ENDIF 
 
 
!--- 2D Script 

RECT2 0, 0, A, h1  
ADD2 1, 0 
RECT2 0, 0, A, h2 
DEL 1&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
 &lt;BR /&gt;
What happens is that 'gap'  is added/subtracted TWICE every time I change 'method' (in my example, B goes from 1000 to 2000 instead of 1500 when method goes from 1 to 2).&lt;BR /&gt;
 &lt;BR /&gt;
So I changed the Parameter Script to this:  &lt;BR /&gt;
 
&lt;PRE&gt;!--- Parameter Script 
 
VALUES "method" 1, 2 
 
IF GLOB_MODPAR_NAME = "method" THEN  
   IF method = 1 THEN  
      PARAMETERS B = B-(gap/2) 
   ELSE  
      PARAMETERS B = B+(gap/2) 
   ENDIF  
ENDIF 
&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
And the code works as expected. But in the real-life objects I intend to write, it won't be so easy to compensate this difference. &lt;BR /&gt;
 &lt;BR /&gt;
So the question is: why the code within 'IF GLOB_MODPAR_NAME....' is executed twice when I change the parameter only onceand how could I correct this misbehavior?&lt;/R&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Jul 2015 16:45:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287181#M9870</guid>
      <dc:creator>Durval</dc:creator>
      <dc:date>2015-07-29T16:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to change parameters and keep dimensione of an objec</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287182#M9871</link>
      <description>The object is attached.</description>
      <pubDate>Wed, 29 Jul 2015 16:49:19 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287182#M9871</guid>
      <dc:creator>Durval</dc:creator>
      <dc:date>2015-07-29T16:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to change parameters and keep dimensione of an objec</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287183#M9872</link>
      <description>Hi Durval,&lt;BR /&gt;
&lt;BR /&gt;
This happens because the parameter script can be run multiple times, thus resulting in the calculation occurring twice or more.  I had this exact problem last year and it's a simple solution.  &lt;A href="http://archicad-talk.graphisoft.com/viewtopic.php?p=238609&amp;amp;highlight=#238609" target="_blank"&gt;Here&lt;/A&gt; is the topic I started.  It has a working object in my last reply.  Essentially you need to insert the code below from Michael Rensing (&lt;A href="http://archicad-talk.graphisoft.com/viewtopic.php?t=34828&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc&amp;amp;highlight=isfirstrun" target="_blank"&gt;Found in this topic&lt;/A&gt;) which only runs part of the script if it is the first time the script is being run. &lt;BR /&gt;

&lt;BLOCKQUOTE&gt;Michael wrote:&lt;BR /&gt;This should do it.&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	n = APPLICATION_QUERY ("PARAMETER_SCRIPT", "FIRSTOCCASION_IN_PROGRESS", isFirstRun)
	IF isFirstRun THEN
		A=A+1
	ELSE
		A=A
	ENDIF
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 30 Jul 2015 23:37:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287183#M9872</guid>
      <dc:creator>Lachlan Green</dc:creator>
      <dc:date>2015-07-30T23:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to change parameters and keep dimensione of an objec</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287184#M9873</link>
      <description>Create 2 new Parameters:&lt;BR /&gt;
  h = 1000&lt;BR /&gt;
  gap = 500&lt;BR /&gt;
---------------------------------&lt;BR /&gt;
&lt;BR /&gt;
h1 = h&lt;BR /&gt;
h2 = h+gap&lt;BR /&gt;
&lt;BR /&gt;
IF method=1 THEN&lt;BR /&gt;
  PARAMETERS B=h1&lt;BR /&gt;
ELSE&lt;BR /&gt;
  PARAMETERS B=h2&lt;BR /&gt;
ENDIF</description>
      <pubDate>Fri, 21 Aug 2015 07:00:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/How-to-change-parameters-and-keep-dimensione-of-an-object/m-p/287184#M9873</guid>
      <dc:creator>LiHigh</dc:creator>
      <dc:date>2015-08-21T07:00:21Z</dc:date>
    </item>
  </channel>
</rss>

