a week ago
Hello,
So I have this simple rectangle that stretches in two directions. I can use either A and B or in the example, I use an array parameter. I want to know how many resizings I've done with the object so I increment my counter by 1 every time I modify my array.
- coords is a length type 1-dimensional array
- counter is an integer type parameter
The 2D is very simple but I have a combined hotspot that causes issues with the incrementation : if I only have one hotspot for X (or for Y) then the increment works fine but if I use a combined hotpost, any change increments the counter by 2.
hs = 0
rect2 0, 0, coords[1], coords[2]
! If there is only one hotspot, incrementation is fine
hotspot2 0 , coords[2] , hs, coords[1], 1 : hs = hs + 1
hotspot2 coords[1] , coords[2] , hs, coords[1], 2 : hs = hs + 1
hotspot2 -1 , coords[2] , hs, coords[1], 3 : hs = hs + 1
! If I add the second one to combine them, I have an issue
hotspot2 coords[1] , 0 , hs, coords[2], 1 : hs = hs + 1
hotspot2 coords[1] , coords[2] , hs, coords[2], 2 : hs = hs + 1
hotspot2 coords[1] , -1 , hs, coords[2], 3 : hs = hs + 1
Here is the code in the Master script
isFirstRun = 0
n = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
if isFirstRun and GLOB_MODPAR_NAME = "coords" then
counter = counter + 1
else
counter = counter
endif
parameters counter = counter
I use isFirstRun and GLOB_MODPAR_NAME to be sure that the counter is only triggered when I resize. I also tried to check Parameter script runs once in Compatibility Options but to no avail.
If I directly modify the array in the object's options, then there is no issue whether I have a single or a combined hotspot. But I want the resizing to be dynamic so manually modifying the array is not good.
Any idea ?
Solved! Go to Solution.
yesterday - last edited yesterday
Yeah, that was the variable I was thinking of, and being able to query each axis independently, but alas neither worked...
Maybe if you stored the existing value in a hidden parameter for comparison? Even more convoluted, but then you can query if the parameter has actually changed rather than just modified to the same value.
IF coords_x_old # coords_x then counter = counter + 1
Probably need an EPS value in there to have it not throw accuracy concerns.
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
Monday
No solution ? 😭
I created a cube from this for testing and added a 3rd parameter to the combined hotspot and it resulted in incrementations by 3.
So my guess is that the number of impacted parameters in a dynamic hotspot will trigger the same number of runs of the Parameter script ? Hence why I cannot increment it by 1 to calculate the number of modifications ? Am I understanding this right ?
Also, why is directly modifying the 3 values in the array parameter not resulting in the same "issue" ?
Wednesday
I would guess that when modifying a combined Hotspot, all of the related parameters are "modified" even if their value does not actually change. So in the original case, your hotspot is modifying both coords[1] and coords[2], resulting in it triggering your stepper twice. You could try turning off the editting preview as that will prevent most of the scripts running till you release the Hotspot. I do not currently remember where the setting is off the top of my head...
Is there really a need to use an array instead of just coords_x, coords_y, coords_z?
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
Wednesday
Thanks for the reply 👍
There's no real need to have an array, I had chosen that way because it was more elegant.
However even when using single parameters for each coord, the result seems to be the same. I replaced my code with the one below (changed the 2D and 3D accordingly as well) and the increments are by 3 in the 3D view and 2 in the 2D view. So the issue really seems to be stemming from the combined hotspots.
if isFirstRun and \
(GLOB_MODPAR_NAME = "coords_x" or \
GLOB_MODPAR_NAME = "coords_y" or \
GLOB_MODPAR_NAME = "coords_z") then
counter = counter + 1
else
counter = counter
endif
parameters counter = counter
I also tried to use the GLOB_FEEDBACK_MODE (which I guessed was the variable you hinted at) and it didn't solve this issue either. Neither in the Master script or in the geometric scripts. Maybe what I'm trying to do is not possible or maybe I need to look at the issue from a different perspective because I don't see it at the moment 😅
yesterday - last edited yesterday
Yeah, that was the variable I was thinking of, and being able to query each axis independently, but alas neither worked...
Maybe if you stored the existing value in a hidden parameter for comparison? Even more convoluted, but then you can query if the parameter has actually changed rather than just modified to the same value.
IF coords_x_old # coords_x then counter = counter + 1
Probably need an EPS value in there to have it not throw accuracy concerns.
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |
yesterday
Well thanks, it worked 😮
Basically, what I did was use both coords[] and coords_x, coords_y and coords_z but I changed the hotspots' coordinates with coords_x and coords_y while keeping the parameter reference with coords[]
hotspot2 0 , coords_y , hs, coords[1], 1 : hs = hs + 1
hotspot2 coords_x , coords_y , hs, coords[1], 2 : hs = hs + 1
hotspot2 -1 , coords_y , hs, coords[1], 3 : hs = hs + 1
hotspot2 coords_x , 0 , hs, coords[2], 1 : hs = hs + 1
hotspot2 coords_x , coords_y , hs, coords[2], 2 : hs = hs + 1
hotspot2 coords_x , -1 , hs, coords[2], 3 : hs = hs + 1
Then as you suggested I just added a comparison between the coordinates and the param reference and then my increment is now by 1 every time 👍