Notifications
Clear all

[Closed] Get Local transform in Maxscript

Hi all!

Is there a way to get the local transform of an object in Maxscript?

Bye!
Alex

4 Replies

Read the manual.

MaxScript Language Reference / 3ds Max Objects / Node: MAXWrapper / Node Common Properties.

1 Reply
(@monopoli)
Joined: 10 months ago

Posts: 0

Maybe I’m a super noob, or simply I’m stupid, but I had just looked at that page and now I’ve looked it again, but I can’t find nothing about local transforms.

Maybe you can help me

That’s ok.

Here I cut and paste from the manual.

I think you wanted <node>.transform

[color=white][font=Verdana]Node Transform Properties[/color][/font]

[left][font=Verdana]Unless otherwise noted, the following transform properties are always interpreted with respect to the current working coordinate system as defined by the currently active [/font][font=Verdana]coordsys context[/font][font=Verdana]. The default [/font][font=Courier New]coordsys[/font][font=Verdana] is [/font][font=Courier New]world[/font][font=Verdana]. The [/font][font=Courier New]pos[/font][font=Verdana], [/font][font=Courier New]rotation[/font][font=Verdana], and [/font][font=Courier New]scale[/font][font=Verdana] properties of a node are aliases to the corresponding subcontroller for the node[/font][font=Verdana]’[/font][font=Verdana]s transform controller. If the transform controller does not have one of these subcontrollers, accessing the corresponding node property will result in an “Unknown property” error message. For example, the LookAt controller does not have a Rotation subcontroller, and the IK controller does not have any subcontrollers. You can still access the transform values using the Matrix3 properties of the node[/font][font=Verdana]’[/font][font=Verdana]s [/font][font=Courier New]transform[/font][font=Verdana] property, for example, [/font][font=Courier New]objpos=obj.transform.translationpart[/font][font=Verdana].[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]transform[/font][font=Courier New] : Matrix3 [/font][color=green][font=Courier New]– can read/write to. If written to,[/color][/font]
[/left]
[left][font=Courier New]: [/font][color=green][font=Courier New]the Matrix3 value is decomposed into its[/color][/font]
[/left]
[left][font=Courier New]: [/font][color=green][font=Courier New]position, rotation, and scale values, and these[/color][/font]
[/left]
[left][font=Courier New]: [/font][color=green][font=Courier New]values are stored in the respective position,[/color][/font]
[/left]
[left][font=Courier New]: [/font][color=green][font=Courier New]rotation, and scale controllers, if those[/color][/font]
[/left]
[left][font=Courier New]: [/font][color=green][font=Courier New]controllers exist and can be written to.[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]pos[/font][font=Courier New] : Point3 [/font][color=green][font=Courier New]–can use .position synonym throughout[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]pos.controller[/font][font=Courier New] : Controller [/font][color=green][font=Courier New]–can use .track synonym throughout[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]pos.isAnimated[/font][font=Courier New] : Boolean, read-only [/font][color=green][font=Courier New]–true if position is animated[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]pos.keys[/font][font=Courier New] : MAXKeyArray[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]pos.track[/font][font=Courier New] : Controller [/font][color=green][font=Courier New]–synonym of .pos.controller[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation [/font][font=Courier New]: Quat[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.x_rotation[/font][font=Courier New] : Float [/font][color=green][font=Courier New]–X rotation of node[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.y_rotation[/font][font=Courier New] : Float [/font][color=green][font=Courier New]–Y rotation of node[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.z_rotation[/font][font=Courier New] : Float [/font][color=green][font=Courier New]–Z rotation of node[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.controller[/font][font=Courier New] : Controller [/font][color=green][font=Courier New]–can use .track synonym throughout[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.isAnimated[/font][font=Courier New] : Boolean, read-only [/font][color=green][font=Courier New]–true if rotation is animated[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.keys[/font][font=Courier New] : MAXKeyArray[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]rotation.track[/font][font=Courier New] : Controller [/font][color=green][font=Courier New]–synonym of .rotation.controller[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]scale[/font][font=Courier New] : Point3 [/font][color=green][font=Courier New]– fraction[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]scale.controller[/font][font=Courier New] : Controller [/font][color=green][font=Courier New]–can use .track synonym throughout[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]scale.isAnimated[/font][font=Courier New] : Boolean, read-only [/font][color=green][font=Courier New]–true if scale is animated[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]scale.keys[/font][font=Courier New] : MAXKeyArray[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]scale.track[/font][font=Courier New] : Controller [/font][color=green][font=Courier New]–synonym of .scale.controller[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]dir[/font][font=Courier New] : Point3 [/font][color=green][font=Courier New]– local z-axis direction vector[/color][/font]
[/left]
[left][font=Verdana]Rotates node so that the node[/font][font=Verdana]’[/font][font=Verdana]s Z axis points in the specified direction. The node is rotated around its Z axis such that the Y axis points as much as possible in the world -Z direction.[/font]
[/left]
[left][font=Verdana]Getting and setting [/font][font=Courier New]<node>.dir[/font][font=Verdana] now respects the current coordinate system. Previously, this property was always in world coordinates.[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]max[/font][font=Courier New] : Point3, read-only –[/font][color=green][font=Courier New]max coordinates of node[/color][/font][color=green][font=Courier New]’[/color][/font][color=green][font=Courier New]s bounding box[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]min[/font][font=Courier New] : Point3, read-only[/font][color=green][font=Courier New] –min coordinates of node[/color][/font][color=green][font=Courier New]’[/color][/font][color=green][font=Courier New]s bounding box[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]center[/font][font=Courier New] : Point3 [/font][color=green][font=Courier New]– coordinates of center of node[/color][/font][color=green][font=Courier New]’[/color][/font][color=green][font=Courier New]s bounding box[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]transform[/font][font=Courier New] : Matrix3 [/font][color=green][font=Courier New]– node[/color][/font][color=green][font=Courier New]’[/color][/font][color=green][font=Courier New]s main transformation matrix[/color][/font]
[/left]
[left][font=Verdana]Note [/font]
[/left]
[left][font=Verdana]R[/font][font=Verdana]otation in the internal transformation matrices is [/font][font=Verdana]left-handed[/font][font=Verdana] in contradiction to the [/font][font=Verdana]3ds Max[/font][font=Verdana] user interface and MAXScript. Take care when mixing rotation derived from these matrices and rotation used in rotation-related functions or from rotation properties.[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]pivot[/font][font=Courier New] : Point3 [/font][color=green][font=Courier New]– node[/color][/font][color=green][font=Courier New]’[/color][/font][color=green][font=Courier New]s pivot point position[/color][/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]objectOffsetPos[/font][font=Courier New] : Point3[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]objectOffsetRot[/font][font=Courier New] : Quat[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]objectOffsetScale[/font][font=Courier New] : Point3[/font]
[/left]
[left][font=Verdana]Node geometry[/font][font=Verdana]’[/font][font=Verdana]s position, rotation, and scale offset from the pivot in world coordinates.[/font]
[/left]
[left][font=Courier New]<node>.[/font][font=Courier New]objectTransform[/font][font=Courier New] : Matrix3, read-only[/font]
[/left]
[left][font=Verdana]Node geometry[/font][font=Verdana]’[/font][font=Verdana]s offset in world coordinates.[/font]
[/left]
[left][font=Verdana]Script: [/font]
[/left]
[left][color=green][font=Courier New]– Setting a node[/color][/font][color=green][font=Courier New]’[/color][/font][color=green][font=Courier New]s rotation relative to world space without [/color][/font]
[/left]
[left][color=green][font=Courier New]– messing with its position:[/color][/font]
[/left]
[left][color=blue][font=Courier New]fn[/color][/font][font=Courier New] setNodeWorldRotation theNode theRot = [/font]
[/left]
[left][font=Courier New]([/font]
[/left]
[left][color=blue][font=Courier New]in[/color][/font][font=Courier New] [/font][color=blue][font=Courier New]coordsys[/color][/font][font=Courier New] (transmatrix theNode.transform.pos) [/font]
[/left]
[left][font=Courier New]theNode.rotation = theRot[/font]
[/left]
[left][font=Courier New])[/font]
[/left]
[left]
[/left]
[left][font=Courier New]setNodeWorldRotation $ (eulerangles 45 45 0)[/font]
[/left]
[left]
[/left]
[left][font=Verdana]See also[/font]
[/left]
[left][font=Verdana]Using Node Transform Properties[/font][font=Verdana] [/font]
[/left]

 eek

Controllers in max a relative to a transform space there working in – i.e there local. This is except position/orientation constraints which work in an additive world space (odd) method. To get a local value of an object you can call its controller:

$object.transform.controller[axis].value

e.g $box01.pos.controller[2].value

These methods rely on the object having a controller on its position or rotation. If you just do $.pos.x with an object with no parent or no controller it will be in world space.

Calling an objects transform $.transform.pos will call its matrix transformation relative to the true world space unless you transform it into a local or target space ($.transform * $target.transform) *inverse needed respectively.