[Closed] Position in maxscript
Hi,
I’d like to know how to access to the position information of any object in maxscript. Specially to the position of a sun i’ve created.
Thanks
as far as I know …
positions in max script is defined like that [x,y,z]
$.pos = [100,100,0]
and you can access position on a particular axis like that
$.pos.x = 100
$.pos.y = 100
$.pos.z = 100
or you could use the transform matrix of the object…
Transform_matrix = $.transform
Transform_matrix.row4 = [10,10,0] – x,y,z
$.transform = Transform_matrix
more info on this in the Max help:
Matrix3_Values : properties
I’ve already tried it succesfully with other objects, but it throws the following error with a Skylight sun light:
$Sun02.pos
– Unknown property: “pos” in $Free_Directional_Light:Sun02@[286.083527,-62.728821,93.711525]
I really want to get that three little numbers in brackets in a non error message!!
Thanks
$ shouldn’t be used in scripts. It’s a great shorthand for prototyping in the Listener but it can cause problems elsewhere, as you’ve seen. A better approach is to assign the node you want to query to a variable and then address that variables properties for the values in which you are interested.
MyLight = getNodeByName "Sun02"
You can now query MyLight.pos, MyLight.pos.X, MyLight.pos.Y or MyLight.pos.Z for either the entire point3 position or each individual component of the point3.
Your posted error message is cofnusing to me. The class of a skylight node is “Skylight”, not “Free_Directional_Light”. Are you sure Sun02 is the correct node you are looking for in your scene?
That’s right, my last post wasn’t correct I didn’t create a skylight node. Anyway, I haven’t been able to get the position of the Free_Directional_Light. I know this light is not emitted from an especific point but at least, I’d like to get the position of the helper that 3ds draws for you without attaching a Dummy to it.
If you create a Sunlight system, you get a compass and a free directional light. The light node does not have a transformation controller, instead it is being controlled by a daylight controller with geographical UI and day / time inputs. So the only way to get the position calculated by that controller is to use the .row4 of the .transform property as suggested earlier in this thread:
$Sun01.transform.row4 –> gives the position
point pos:$Sun01.transform.row4 –> creates a point helper at the sun’s position!