GDL
About building parametric objects with GDL.
SOLVED!

Fixed dimensions for multiple models in a single object

Richard Molnar
Booster

Hi All,

 

I am hoping that there is somebody who can help me find the solution as Graphisoft support redirected me to gdl.graphisoft website where I couldn't find the answer.

 

I have 1 single object with multiple models in it and I learned how to switch between the different models. My problem is that the models in the object have different dimensions which all should be fixed. I am sure I can figure out how to make the dimensions fixed and unchangeable, but what I couldn't find an answer to is how to make sure that the placed object's dimensions are set to the picked model. At the moment, all the other options are stretched to the same size as the first/default model. Ticking the box for 'Use Stored Environment' does not do anything to this.

 

Also, I made sure to have only 1 hotspot for each model as they will be connected to another object at the same point,

but when I change the already placed object to a different model it gets relocated. Is there a way to do this too? (It is like having multiple shaped and sized bulbs in 1 bulb object and changing the already placed object will change where the base of the bulb is. My object is not a bulb, btw.)

 

I am a beginner in GDL scripting and since it is not required for my work daily (neither weekly, monthly, or even quarter yearly), I only pick up new knowledge when I need it. But only if I can find it on the internet.

 

I would greatly appreciate your help.

Richard Molnar
AC 6.5-9.0 & 19-27 (latest build)
Windows 10 Pro
Intel i7-6700K 4.00GHz Quad Core, 32GB RAM, NVIDIA Quadro K1200
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Note: locking prevents the values from changing

the parameters command will reset the value even if a user types in a differnt value

 

the variable name for the if/then statement.gatePos should not be in quotes.

this will work:

 

if gatePos = "Closed" then
    a = 2.416
    b = 0.393
    zzyzx = 1.363
    parameters a=2.416
    parameters b=0.393
    parameters zzyzx=1.363
endif

if gatePos = "Open" then
    a = 1.707
    b = 0.327
    zzyzx = 1.140
    parameters a=1.707
    parameters b=0.327
    parameters zzyzx=1.140
endif

 

this assumes that

gatePos is an Abc variable (text) in the parameters list

 

AllanP_0-1729721238427.png

 

 

you have a line in the master script or the parameter script giving a list of values

 

AllanP_3-1729717476540.png

 

then this bit of script should work

 

AllanP_2-1729717381504.png

 

when you change the value in the parameters view, a,b,zzyzx will automatically change

 

AllanP_6-1729717751927.png

 

also

if "gatePos" = "Closed" then

endif

these asks if the word "gatePos" is the same as the word "Closed"

which always gives you a False answer

 

if gatePos = "Closed" then

endif

these asks if the contents of the variable gatePos is the same as the word "Closed", i.e. it replaces gatePos with "Closed" or "Open"

which gives you a True or False answer

 

if the variable is a number type, then you do not need the quotes,

i.e.

if A = 1.5 then

 

endif

 

due to archicad using floating point variables, then there can be very small changes in very small numbers, so you cant ask

if a = 0 then

endif

 

you normally say

tol = 0.0001

if abs(a) < tol then

 

endif

 

or

if abs(a-1.5) < tol then

 

endif

i.e. if the absolute value of a is within 0.1mm of 0 then...

i.e. if the absolute value of a is within 0.1mm of 1.5m then...

you will see that in the script generated from objects close to the origin you will often get numbers like

-6.938893903907E-018

 

the add line in your 3D model will effect origins as it happens after the multiplications. this may be why the hotspot moves all the time

the same for the Add2 in the 2D script

 

where possible, draw an object at the project 0,0 point, it makes it easier placing/changing between different objects

 

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

View solution in original post

11 REPLIES 11
Lingwisyer
Guru

If they were autogenerated, near the start of the scripts there will be a MUL command that relates A and B to their original dimensions. If you just comment this line out, the object should stop scaling. There maybe multiple of these if you have simply merged multiple scripts.

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
AllanP
Expert

parameters a and b are the values in the info box

AllanP_0-1729660728492.png

AllanP_2-1729660816595.png

remember the units in the gdl script are in meters

if you have code in the master script....

 

if user_choice = 1  then

    a = 1

    b = 1

!then you have to update the parameters in the parameters list so...

    parameters a= 1

    parameters b =1

endif

if user_choice = 2  then

    a = 2

    b = 1.5

    parameters a= 2

    parameters b =1.5

endif

if user_choice = 3  then

    a = 1

    b = 4

    parameters a= 1

    parameters b =4

endif

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)
Lingwisyer
Guru

Unless you need to schedule these two sizes, I would just get the script to ignore them.

 

If you want you can add the following to the Master Script in order to HIDE the parameters on the toolbar;

 

HIDEPARAMETER "A"
HIDEPARAMETER "B"

 

,and in the Parameters List click on the X to hide them on the object window.

Lingwisyer_0-1729666633749.png

 

 

 

If you do what Allan is suggestion, I would suggest LOCKing the parameters to prevent people inserting faux sizes;

 

LOCK "A"
LOCK "B"

 

 

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Dear Allan,

 

Thank you for the help, however it does not work for some reason.

 

I have this in the Master Script and when checked it says ok, but the object in option 2 (Open) is still stretched:

 

if "gatePos" = "Closed" then
a = 2.416
b = 0.393
zzyzx = 1.363
parameters a=2.416
parameters b=0.393
parameters zzyzx=1.363
endif

if "gatePos" = "Open" then
a = 1.707
b = 0.327
zzyzx = 1.140
parameters a=1.707
parameters b=0.327
parameters zzyzx=1.140
endif

LOCK "A"
LOCK "B"
LOCK "ZZYZX"

 

I am not sure what could be a problem. The origin of the models in the object were morphs save to individual objects and then their 3D scripts were combined. Not sure if this matters for the outcome.

Richard Molnar
AC 6.5-9.0 & 19-27 (latest build)
Windows 10 Pro
Intel i7-6700K 4.00GHz Quad Core, 32GB RAM, NVIDIA Quadro K1200

Thank you Lingwisyer,

 

The locking script is working although the stretching of option 2 is still happening and I replied to Allan about it.

Richard Molnar
AC 6.5-9.0 & 19-27 (latest build)
Windows 10 Pro
Intel i7-6700K 4.00GHz Quad Core, 32GB RAM, NVIDIA Quadro K1200

I tried Allan's suggestion, but it doesn't seem to work, so I will try with yours.

 

RichardMolnar_0-1729679426839.png

 

So you are saying I should remove these lines?

Richard Molnar
AC 6.5-9.0 & 19-27 (latest build)
Windows 10 Pro
Intel i7-6700K 4.00GHz Quad Core, 32GB RAM, NVIDIA Quadro K1200
Solution

Note: locking prevents the values from changing

the parameters command will reset the value even if a user types in a differnt value

 

the variable name for the if/then statement.gatePos should not be in quotes.

this will work:

 

if gatePos = "Closed" then
    a = 2.416
    b = 0.393
    zzyzx = 1.363
    parameters a=2.416
    parameters b=0.393
    parameters zzyzx=1.363
endif

if gatePos = "Open" then
    a = 1.707
    b = 0.327
    zzyzx = 1.140
    parameters a=1.707
    parameters b=0.327
    parameters zzyzx=1.140
endif

 

this assumes that

gatePos is an Abc variable (text) in the parameters list

 

AllanP_0-1729721238427.png

 

 

you have a line in the master script or the parameter script giving a list of values

 

AllanP_3-1729717476540.png

 

then this bit of script should work

 

AllanP_2-1729717381504.png

 

when you change the value in the parameters view, a,b,zzyzx will automatically change

 

AllanP_6-1729717751927.png

 

also

if "gatePos" = "Closed" then

endif

these asks if the word "gatePos" is the same as the word "Closed"

which always gives you a False answer

 

if gatePos = "Closed" then

endif

these asks if the contents of the variable gatePos is the same as the word "Closed", i.e. it replaces gatePos with "Closed" or "Open"

which gives you a True or False answer

 

if the variable is a number type, then you do not need the quotes,

i.e.

if A = 1.5 then

 

endif

 

due to archicad using floating point variables, then there can be very small changes in very small numbers, so you cant ask

if a = 0 then

endif

 

you normally say

tol = 0.0001

if abs(a) < tol then

 

endif

 

or

if abs(a-1.5) < tol then

 

endif

i.e. if the absolute value of a is within 0.1mm of 0 then...

i.e. if the absolute value of a is within 0.1mm of 1.5m then...

you will see that in the script generated from objects close to the origin you will often get numbers like

-6.938893903907E-018

 

the add line in your 3D model will effect origins as it happens after the multiplications. this may be why the hotspot moves all the time

the same for the Add2 in the 2D script

 

where possible, draw an object at the project 0,0 point, it makes it easier placing/changing between different objects

 

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

Those are indeed the lines in question. The number on the right side will be the original objects dimensions, so when it is set, your object is not scaled, but when you change A & B in the case of your alternate objects, these will no longer be equal to 1 and hence stretch along the relevant axis.

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Locking only prevents user modification of said values, they can still be changed within the script. Given predefined A & B sizes, it can be good to lock them as to prevent faux value inputs while still allowing for quick referencing of the sizes. Alternatively, you could write a whole new script to round the user inputted value to the nearest valid value, propogate said value into the other scripts and override the parameter with the new valid value.

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660