ulukai33
02-01-2005, 07:07 PM
Hi,
I would never think I will do something with maxscript. My only experience with programming is a few simple "things" in pascal when I was on high school years ago (good old days :twisted: ).
But now, I needed to use freeze/restore rotation (in animation quad). I have found out that this works only with Eulers (if you have tcb, it will setup eulers). So I thought I will edit the script to work with TCB. What a heroic thing from me :) .
I have cut out everything except freeze and restore rotation (there is position and transformation too). Than I have edited the script. It almost works (freezes the rotation), but when I try to use TCB Rotation To Zero it says that rotation was never frozen.
Here is the script:
*/
-- Freeze TCB Rotation Only
macroScript FreezeTCBRotation
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"Freeze TCB Rotation"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"Freeze TCB Rotation"
(
fn FreezeTCBRotation =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller = TCB_rotation()
CurObj.rotation.controller = Rotation_list()
/* "Localization on" */
CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.available.controller = TCB_rotation()
CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.setname 2 "Keyframe TCB"
CurObj.rotation.controller.SetActive 2
/* "Localization off" */
)
/* "Localization on" */
Catch( messagebox "A failure occurred while freezing an object's rotation." title:"FreezeTCBRotation")
/* "Localization off" */
)
select Obj
)
FreezeTCBRotation()
)
--Set TCB Rotation to Zero
MacroScript TCBRotationToZero
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"TCB Rotation To Zero"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"TCB Rotation To Zero"
(
fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].x_rotation = 0
CurObj.rotation.controller[2].y_rotation = 0
CurObj.rotation.controller[2].z_rotation = 0
CurObj.rotation.controller[2].angle = 0
)
/* "Localization on" */
Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")
/* "Localization off" */
)
select Obj
)
TCBRotationToZero()
)
I have simply replaced every sign of Euler_xyz with TCB_rotation.
I think problem is here:
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].x_rotation = 0
CurObj.rotation.controller[2].y_rotation = 0
CurObj.rotation.controller[2].z_rotation = 0
CurObj.rotation.controller[2].angle = 0
)
/* "Localization on" */
Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")
I don't know how exactly re-set the values of TCB to zero, I have added CurObj.rotation.controller[2].angle = 0 line, but I think that's what is not working.
Could someone help please :sad: ???
I would never think I will do something with maxscript. My only experience with programming is a few simple "things" in pascal when I was on high school years ago (good old days :twisted: ).
But now, I needed to use freeze/restore rotation (in animation quad). I have found out that this works only with Eulers (if you have tcb, it will setup eulers). So I thought I will edit the script to work with TCB. What a heroic thing from me :) .
I have cut out everything except freeze and restore rotation (there is position and transformation too). Than I have edited the script. It almost works (freezes the rotation), but when I try to use TCB Rotation To Zero it says that rotation was never frozen.
Here is the script:
*/
-- Freeze TCB Rotation Only
macroScript FreezeTCBRotation
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"Freeze TCB Rotation"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"Freeze TCB Rotation"
(
fn FreezeTCBRotation =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller = TCB_rotation()
CurObj.rotation.controller = Rotation_list()
/* "Localization on" */
CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.available.controller = TCB_rotation()
CurObj.rotation.controller.setname 1 "Inital Rotation"
CurObj.rotation.controller.setname 2 "Keyframe TCB"
CurObj.rotation.controller.SetActive 2
/* "Localization off" */
)
/* "Localization on" */
Catch( messagebox "A failure occurred while freezing an object's rotation." title:"FreezeTCBRotation")
/* "Localization off" */
)
select Obj
)
FreezeTCBRotation()
)
--Set TCB Rotation to Zero
MacroScript TCBRotationToZero
enabledIn:#("max", "viz") --pfb: 2003.12.12 added product switch
ButtonText:"TCB Rotation To Zero"
Category:"Animation Tools"
internalCategory:"Animation Tools"
Tooltip:"TCB Rotation To Zero"
(
fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].x_rotation = 0
CurObj.rotation.controller[2].y_rotation = 0
CurObj.rotation.controller[2].z_rotation = 0
CurObj.rotation.controller[2].angle = 0
)
/* "Localization on" */
Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")
/* "Localization off" */
)
select Obj
)
TCBRotationToZero()
)
I have simply replaced every sign of Euler_xyz with TCB_rotation.
I think problem is here:
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].x_rotation = 0
CurObj.rotation.controller[2].y_rotation = 0
CurObj.rotation.controller[2].z_rotation = 0
CurObj.rotation.controller[2].angle = 0
)
/* "Localization on" */
Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")
I don't know how exactly re-set the values of TCB to zero, I have added CurObj.rotation.controller[2].angle = 0 line, but I think that's what is not working.
Could someone help please :sad: ???
