Quantcast
Channel: ArchiCAD-Talk - Libraries / Library Parts / GDL
Viewing all articles
Browse latest Browse all 3838

How to change parameters and keep dimensione of an object?

$
0
0
Author:Durval
Posted: Wed Jul 29, 2015 5:45 pm (GMT+1)


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.

It draws two rectangles. The second rectangle is always the height of the first plus a constant 'gap'.

There is a parameter called 'method', whose value can be 1 ou 2.

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.

If method = 2, then ' B' should be the height of the second rectangle (h2=B), so h1=B-gap.

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.

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.

I wrote these scripts:

Code:
 
!---- 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



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).

So I changed the Parameter Script to this:

Code:
!--- 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


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.

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?
_________________
--- www.dtabach.com.br ---
AC 17 INT MacBook Pro i7 8GB RAM Mac OSX 10.9.5


Viewing all articles
Browse latest Browse all 3838

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>