2023-11-27 03:15 PM - last edited on 2024-09-26 01:45 PM by Doreena Deng
Hi,
How can I lock the ratio A/B of an object so it's now skewable?
Again I can't choose GDL asa label when posting...
/Mats
2023-11-27 03:37 PM
Do you mean so it sticks as A = 100mm & B = 200mm and can't be changed or have it so if after stretching A = 200mm so B will change to 400mm?
Are you using stretchy hotspots or just typing in A/B?
2023-11-27 03:44 PM
@DGSketcher wrote:Do you mean so it sticks as A = 100mm & B = 200mm and can't be changed or have it so if after stretching A = 200mm so B will change to 400mm?
Are you using stretchy hotspots or just typing in A/B?
Yes, it's a rescale basically...
Stretchy hotspots 🙂 (sounds cool btw)
2023-11-27 04:05 PM
You need to store a variable objRatio = A/B
Then in the Parameter Script use GLOB_MODPAR_NAME to do something along the lines of...
objRatio = A/B !stores current ratio
if GLOB_MODPAR_NAME = "A" then
B = A / objRatio
parameters B = B
endif
if GLOB_MODPAR_NAME = "B" then
A = B * objRatio
parameters A = A
endif
This will give priority to the A value if both are changed. I haven't tested this but it should point you in the right direction.
You should have a look in the GDL guide for HOTSPOTS if you aren't already using them.
2023-11-28 02:42 AM
@Mats Knutsson wrote:
Again I can't choose GDL asa label when posting...
There is a separate GDL forum in the Developer Hub section.
The other forum is just about the use of the libraries and object, not the scripting of them.
I have moved this post there.
Barry.
2023-11-28 04:55 AM - edited 2023-11-28 04:59 AM
Alternatively, given it is just scaling, do you even need to have the two variables editable? Could you just use a single variable and a MUL command?
Using a scale factor of x: MUL2 A(x), B(x)
Using the original size x of A: MUL2 x/A, x/A
MUL A/0.24, A/0.24, A/0.24
BRICK 0.24, 0.09, 0.086
Ling.
Derp, none of the available fonts are cursive.... sad x....
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 |
2023-11-28 09:00 AM
If I script them myself I do control stretching but this is just for quick and dirty DYI-objects that any user can create just by drawing something, select it and save as an object. If the code as DGSketcher kindly wrote down can be copied and pasted it into the object then I'm happy.
2023-11-28 09:50 AM - edited 2023-11-28 09:55 AM
If it is an object that is made simply by using the menu command, they already use MUL to scale. Edit 3 lines and you're done.
2D Script:
!mul2 A/1.000000, B/1.000000
mul2 A/1.000000, A/1.000000 !Line 1
3D Script
!mulx A/ 1
!muly B/ 1
!mulz ZZYZX/ 1
mulx A/ 1
muly A/ 1 !Line 2
mulz A/ 1 !Line 3
ie. You just change all the MUL commands to reference only A. B and ZZYZX will now do nothing. You can swap around to use which ever you want.
Example is from a 1x1x1 box
If you want, you can also hide the now useless parameters by adding the following to the Master Script.
HIDEPARAMTER "B"
HIDEPARAMTER "ZZYZX"
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 |