2024-10-22 11:16 AM
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.
Solved! Go to Solution.
2024-10-23 10:58 PM - last edited on 2024-10-29 09:16 PM by Laszlo Nagy
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
you have a line in the master script or the parameter script giving a list of values
then this bit of script should work
when you change the value in the parameters view, a,b,zzyzx will automatically change
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
2024-10-23 04:56 AM
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 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2024-10-23 07:24 AM
parameters a and b are the values in the info box
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
2024-10-23 08:58 AM - edited 2024-10-23 08:59 AM
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.
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 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2024-10-23 12:25 PM - last edited on 2024-10-29 09:14 PM by Laszlo Nagy
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.
2024-10-23 12:27 PM
Thank you Lingwisyer,
The locking script is working although the stretching of option 2 is still happening and I replied to Allan about it.
2024-10-23 12:30 PM - last edited on 2024-10-29 09:15 PM by Laszlo Nagy
I tried Allan's suggestion, but it doesn't seem to work, so I will try with yours.
So you are saying I should remove these lines?
2024-10-23 10:58 PM - last edited on 2024-10-29 09:16 PM by Laszlo Nagy
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
you have a line in the master script or the parameter script giving a list of values
then this bit of script should work
when you change the value in the parameters view, a,b,zzyzx will automatically change
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
2024-10-24 03:18 AM
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 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2024-10-24 03:23 AM
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 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |