Notifications
Clear all

[Closed] Big problem with node callback position

Hi, my problem seem simple but i’ve tried at least 10 ways to do it that don’t work and I can’t find a thread addressing this issue.

      I'm using 3dsMax 8 to make a utility script that have 3 spinner boxes :
      spnObjectPosX
      spnObjectPosY
      spnObjectPosZ
      
      To make things simple, I have only 1 rectangle shape in my scene and this is how I set a CALLBACK on it :
when transform $ changes object do update_panel_object_data_transform object
      Note that the function receive the object in parameter.
      
      Here is my callback function :
fn update_data_transform object =
          (
              spnObjectPosX.value = object.position.x
              spnObjectPosY.value = object.position.y
              spnObjectPosZ.value = object.position.z
          )
      I have to tell you that the X axis is working fine! BUT NOT THE Y AND Z?!?
      
      Here is my observations of what happen :
      1- Assume that my object is at the center of the world [0,0,0]
      
      2- When I move the object with the gizmo on the X axis the spnObjectPosX is changing to show the current position of the object and everything is working fine.
      
      3- The problem : when I move the object with the gizmo on the Y axis, the spnObjectPosY is showing the position from wich I start moving (in our case 0) and NOT the current position. Moreover, I can see the value of the spinner "flicking" with the good value! But it is always set back to the "starting position" (in our case 0)
      
      4- The same problem occur on the Z axis.

5- If I move the object on the X axis after moving it on the Y axis, the spnObjectPosY suddenly get updated with the right Y value!

      So whats happening, why the object.position.y is returning the origin value while I move the object with the gizmo?? Is it a bug of 3dsmax or am I just not using it the right way.
      
      Any advice would be greatly appreciated.
8 Replies

Can I ask a general question as to what it is overall you are trying to acheive.
It looks to me like you are using callbacks on the object to update the spinner value is this correct ? If so there are other ways to go about this.

Not in front of max right now, but if memory serves me correctly it’s a bug with the position xyz controller… I seem to recall if you change this controller to something else, say bezier position, it should work.

yes i also remember this problem as a position_xyz controller bug.

but any way you should not use callbacks for that purpose, for example, if the object is animated, when you change the slider time the utility spinners wont update.
You can also try using a script controller and using the object position controller as a variable and the update function inside. when the position changes the script is executed, the time change is considered and the position_xyz bug wont be a problem as well.

It is one of the known bugs. Many years max developers transmit this bug as a fetish from version to version.

change you code to:


when transform obj changes handleAt:#redrawViews obj do do_anything_you_want obj

it has to work now

Thank you for your help everyone, i’m testing these proposal and will keep you posted with the results.

First, let me give a BIG thanks to all of you for these very good tips. People here seems to really know their stuff!

Hotknife : to answer your query, what I’m trying to achieve is a level editor for a physic engine generated by all the nodes of a scene in 3dsMAX. And guess what, this little bug with the position_XYZ was the last rock in my shoe! And yes, I’m using callbacks on all the object of a scene to update the position spinners of the utility plugin I’m writing. I’m curious of the “other ways” you where talking about, so if you can, please tell us how you would do it!

Rorschach & phoelix : thank you for your confirmation about the position_xyz bug, I looked very hard on several forums but could not find any thread about this anywhere. I did took 2h today (yeah, it a big complex plugin) to change my code to switch to bezier_position and it did work, but it soon became problematic because the parents of the object became the [0,0,0] position for every child and so I had to manage the relative position of each and it was a bit of a hassle at that point in the development due to the size of the plugin.

denisT : Wow, straight to the point, this little addon

handleAt:#redrawViews

in my callbacks lines just fixed everything.

The final solution (that work for me) is to force a redraw of the viewport in the callback :

when transform obj changes handleAt:#redrawViews obj do do_anything_you_want obj

I can’t thank you enough for this fix because it leave all the rest of my code intact and everything is working so smooth now!

I could not have fix the final bug without all of your insights. I was dragging this bug since the very early development and it was soooo annoying!

So thank you again everyone!

Not sure, but this seems as its supposed to be.
x y z controllers evaluate in order.
when x is evaluated it is considered a transform change, so y and z never get a change in the viewports,
the same with rotation controllers

to evaluate z, it first evaluates x and y // each one a transform change

Sorry not to reply sooner – I think the other guys are far ahead of me. I was just thinking of wiring the x,y,z to the spinners but this is probably not what you needed.