Notifications
Clear all

[Closed] when transform wierdness


deleteAllChangeHandlers id:#test
obj=selection[1]
print obj.position
when transform obj changes id:#test do (print obj.position)

With the above code I get alternating old/new transform data, see sample output below…


$Box:Box296 @ [-190.705658,-8262.199219,0.000000]
[-190.706,-8262.2,0]
[b][-190.706,-8262.2,0][/b]
<ChangeHandler:0x0000c918>

--here I start moving the box--

[-190.706,-8261.66,0]
[b][-190.706,-8262.2,0][/b]
[-190.706,-8255.91,0]
[b][-190.706,-8262.2,0][/b]
[-190.706,-8253.58,0]
[b][-190.706,-8262.2,0][/b]
[-190.706,-8253.4,0]
[b][-190.706,-8262.2,0][/b]
[-190.706,-8253.4,0]

Does anyone know why or how to fix it? (And I can’t use the ‘handleAt:#viewportredraw’ in my script for certain reasons)

10 Replies

do this to your verts

TRANSFORMX = trimesh.verts[yourloop].pos.x – obj.pos.x
TRANSFORMY = trimesh.verts[yourloop].pos.y – obj.pos.y
TRANSFORMZ = trimesh.verts[yourloop].pos.z – obj.pos.z

then you can write TRANSFORMX,Y,Z. They will always appear on the 0,0,0 axis on your pivot point instead of the world matrix.

1 Reply
(@jonadb)
Joined: 11 months ago

Posts: 0

Ehh… are you sure you’re in the right topic?

From what I get out of your post, when you move an objects the verts change. Basically I see in your script it doesn’t account for pivot points. In max when you move the object with pivot point and want to display the correct vert positions from the pivot point then you need to subtract the position of the object from the verts themselves.

example of this would be a box where the first vert is located on -2 of the pivot point, if I move it now it reads -2.964. I moved the object with the pivot point -0.964 on the world matrix so you can see why subtraction is necessary.

you can still use the obj.pos to calculate where your pivot point will be.

1 Reply
(@jonadb)
Joined: 11 months ago

Posts: 0

Sorry I wasn’t clear then This issue I’m having is not pivot/vertex related.

The obj position I’m getting from max in a ‘when transform’ handler is giving me alternating old/new position data when moving an object.

[-190.706, -8262.2, 0] = original object position
[-190.706, **** , 0] = object position while moving it around

You can see the original position ever other line…

Do you need all the positions logged or only the latest?

1 Reply
(@jonadb)
Joined: 11 months ago

Posts: 0

In the real code I have things reacting to the transform data/event, the example code was an as simple scenario as possible to show the problem.

Anyways, thanks for trying!

After looking at it 1000 times I narrowed the problem down. Maxscript seems to want to take your original position and then move it, every time it moves its like a new movement in max so no matter what its gonna show the original point.

If you only need the latest position then this works but if you need to print them all then IDK.

clearlistener()

for obj in geometry do(
global sel=obj
when transform obj changes do (
clearlistener()
print sel.pos
)
)

Maxscript is a live Script Language. So maybe you can cast the type back to point3, save it in a variable and just print the value of the new variable.

You might as well give a try to thehold:

deleteAllChangeHandlers id:#test
obj=selection[1]
print obj.position
when transform obj changes id:#test do if not theHold.Holding() do print obj.position
1 Reply
(@jonadb)
Joined: 11 months ago

Posts: 0

Ahh cheers!