Notifications
Clear all

[Closed] Does anyone have this script?

Somehow the last post didn’t go through (atleast not on my end).

Does anyone have a script that gets each objects position relative to 0,0,0 and puts the values in a file?

Nothing fancy, I just need the coordinates relative to 0.

Thanks!

18 Replies

 txt = ""
 for i in selection do
 (
 	txt += (i.name + " = " + ((coordsys world i.pos) as string) + "
")
 	
 )
 f = createfile "C:\\TEMP\\file.txt"
 format txt to: f
 close f 

change the path

Thanks! Definately appreciate it!

I also need a script like this but besides this info I also need to know the rotational offset and if possible the material name from a multisub. Any help would be appreciated. Thank you very much for what is currently here, and for any help in advance.

Actually, to just get rotation, isn’t too hard, Just needed to change the line from pos to rotation. Since I wanted them both, I compounded it, but the resulting info seems strange, it doesn’t match the info in max. This is the modified script:

txt = ""
 for i in selection do
 (
	 txt += (i.name + " = " + ((coordsys world i.pos) as string) + ((coordsys world i.rotation) as string) + "
")
	 
 )
 f = createfile "C:\\Users\\peter\\Desktop\\file.txt"
 format txt to: f
 close f 

it results with info like this:

Box03 = [-15.7034,-14.2776,0](quat 0 0 -0.382683 0.92388)
Box04 = [7.6776,-14.0195,0](quat 0 0 -0.707107 0.707107)
Box02 = [28.5424,16.2574,0](quat 0 0 -0.999993 -0.00363246)
Box01 = [-14.0552,20.6396,0](quat 0 0 0 1)

I don’t understand why there are 4 sets of numbers in the rotational results nor why those numbers don’t relate to what max shows in its numeric transform.

It’s because they are quaternion values while 3ds max displays Euler coordinates.
You need to convert them, search the maxScript help for “quatToEuler”.

Did anyone manage to modify this script with quatToEuler embedded? I need to use this script also but cannot get the syntax right to include the quatToEuler conversion. (I’m new to maxscript) The position values all work perfectly.

 PEN

You want to be careful using the quatToEuler this way. Euler rotations can wind up and a quat can’t. Try this…

eulerToQuat (eulerAngles 0 0 0)
eulerToQuat (eulerAngles 360 0 0)

Both return the same value. If you are only concerned that the orientation of the object is correct then the quat will do but if you wanted to have the actualy values then you will need to get and print the seperate euler angle values.

You should be able to get what you want by using quattoeuler2:

quatToEuler2 <quat>

Returns the same Euler value for the given Quaternion as shown in the Transform Type-In dialog. Available in 3ds Max 2008 and higher. Previously available in the [AVG] Avguard Extensions.
ScreaminBubba try this, modified the code to use the <node>.transform. context. This returns the Rotation values that match those in the Transformation Type-in dialog, this may differ from those in the Max UI values:

txt = ""
  for i in selection do
  (
 	 txt += (i.name + " = " + ([b](i.transform.position)[/b] as string) +" "+ ([b](quattoeuler2 (i.transform.rotation))[/b] as string) + "
")
 	 
  )
  f = createfile "C:\\Users\\peter\\Desktop\\file.txt"
  format txt to: f
  close f

-Eric

I tried yours pixel monkey, but it gave me this error:

– Type error: Call needs function or class, got: undefined

Page 1 / 2