[Closed] Freeze Rotation, Rotation to Zero for TCB controller
Hi,
I would never think I will do something with maxscript. My only experience with programming is a few simple 鈥渢hings鈥?in pascal when I was on high school years ago (good old days 😈 ).
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:#(鈥渕ax鈥? 鈥渧iz鈥? –pfb: 2003.12.12 added product switch
ButtonText:鈥淔reeze TCB Rotation鈥?
Category:鈥淎nimation Tools鈥?
internalCategory:鈥淎nimation Tools鈥?
Tooltip:鈥淔reeze TCB Rotation鈥?br>
(
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()
)鈥揝et TCB Rotation to Zero
MacroScript TCBRotationToZero
enabledIn:#(鈥渕ax鈥? 鈥渧iz鈥? –pfb: 2003.12.12 added product switch
ButtonText:鈥淭CB Rotation To Zero鈥?br>
Category:鈥淎nimation Tools鈥?br>
internalCategory:鈥淎nimation Tools鈥?br>
Tooltip:鈥淭CB Rotation To Zero鈥?br>
(
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鈥檛 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鈥檚 what is not working.
Could someone help please 🙁 ???
hi,
tcb controllers dont have separate tracks for each axis so try this instead
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller.value = (quat 0 0 0 1)
)
mark tsang
I think that鈥檚 it, thanks. :applause:
-EDIT-
I still get the error message (rotation was never frozen)
-EDIT-
SORRY, IT WORKS. Problem was that after freezing TCB I was using Rotation to Zero and Not TCB to Zero. :banghead:
But I think that 鈥淐urObj.rotation.controller.value = (quat 0 0 0 1)鈥?was important, I think it wouldn鈥檛 work without that.
Well, I have made some beta testing and it doesn鈥檛 work as it should.
If I use Freeze TCB rotation, new controler is created, but when I use TCB Rotation to Zero, objects rotation is restored to zero rotation and not the frozen one.
Any ideas?
are you by any chance zeroing the wrong controller? you should be zeroing the one in slot 2
mark
I鈥檓 doing it this way:
1.) I have put Freeze TCB Rotation and TCB Rotation To Zero to animation quad menu
2.) than I select a object, rotate it a bit (to take it out of default rotation)
3.) than – quad menu/freeze tcb rotation
4.) than I rotate the object to completely different orientation
5.) and finaly – quad/tcb rotation to zero
and the problem is that object rotation is not restored to frozen one, but to the default 0,0,0 (as it was when the object was created)
You think that the script is OKi?
show me the entire script and i will see if i spot anything wrong
mark
Complete script:
/*
Freeze Transform MacroScript FileAuthor : Frederick Ruff
Revision History:
Dec 1 2000, created
Aug 22 2003, Larry Minton
12 dec 2003, Pierre-Felix Breton,
added product switcher: this macroscript file can be shared with all Discreet products
Feb 1 2005, Ulukai, changed to freeze/restore TCB rotationThis script adds tools for freezing a transform
This is done via adding a second controller to the controllers stack.
鈥?**********************************************************************************************
鈥?MODIFY THIS AT YOUR OWN RISK
*/
鈥?Freeze TCB Rotation Only
macroScript FreezeTCBRotation
enabledIn:#(鈥渕ax鈥? 鈥渧iz鈥? –pfb: 2003.12.12 added product switch
ButtonText:鈥淔reeze TCB Rotation鈥?
Category:鈥淎nimation Tools鈥?
internalCategory:鈥淎nimation Tools鈥?
Tooltip:鈥淔reeze TCB Rotation鈥?br>
(
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()
)鈥揝et TCB Rotation to Zero
MacroScript TCBRotationToZero
enabledIn:#(鈥渕ax鈥? 鈥渧iz鈥? –pfb: 2003.12.12 added product switch
ButtonText:鈥淭CB Rotation To Zero鈥?br>
Category:鈥淎nimation Tools鈥?br>
internalCategory:鈥淎nimation Tools鈥?br>
Tooltip:鈥淭CB Rotation To Zero鈥?br>
(
fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller.value = (quat 0 0 0 1)
)/* "Localization on" */ Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform") /* "Localization off" */ ) select Obj
)
TCBRotationToZero()
)
I don鈥檛 know if formating can do something 鈥渂ad鈥?to the script, so here is a link to file:
http://test333.szm.sk/Macro_FreezeTCBRotation.zip
And thanks for the help!
Great site with great people here.
as i susected you were zeroing the wrong controller – which is partial my fault as when i answered earlier i didn鈥檛 specify that you need to indicate which controller.- any way
fn TCBRotationToZero =
(
local Obj = Selection as array
for i = 1 to Obj.count do
(
Try
(
local CurObj = Obj[i]
CurObj.rotation.controller[2].value = (quat 0 0 0 1)
)
/* "Localization on" */
Catch( messagebox "One of the object's rotation was never frozen." title:"Freeze Transform")
/* "Localization off" */
)
select Obj
)
TCBRotationToZero()
mark
Oh鈥? you thought by 鈥渋f I鈥檓 zeroing wrong controller鈥?if I鈥檓 zeroing wrong controller in script? I thought If I鈥檓 not using the script somehow wrong鈥?But I really never did anything in maxscript or any other programming language, so I apologize for my amateurism .
It works perfectly now!
Really, really BIG THANK YOU !!!
There is a one disadvantage with internet, I really don鈥檛 like that I can鈥檛 buy you a beer (or whatever you are drinking) on times like these .
SO ONCE AGAIN – THANKS :wavey: