Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Set bone keyframe tangents to linear with max script

Set bone keyframe tangents to linear with max script

DerSekki
Explorer Explorer
670 Views
2 Replies
Message 1 of 3

Set bone keyframe tangents to linear with max script

DerSekki
Explorer
Explorer

I have following code:

rtb = $myRootBone
deleteKeys rtb
with animate on
(
    at time 0 rtb.pos = [0,0,0]
    at time (animationRange.end) rtb.pos = [0,-200,0]
    c = rtb.pos.controller
    if isProperty c #tangents do
    (
        t = c.tangents
        for j = 1 to t.numKeys do
        (
            t.setTangentType j #linear
            t.setWeight j 0.0
        )
    )
)

 

This script sets a starting and ending keyframe. This works. In the end, it should set the tangents to linear, but it doesn't. Any idea, what could be the problem?

0 Likes
Accepted solutions (1)
671 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

Why should it work? As I know the Controller superclass doesn't have the #tangents property

 

You have at least three options to achieve what you want (linear in/out tangents):

1. Use linear controller:

 

delete objects
b = box isselected:on
b.pos.controller = linear_position()

with animate on
(
	at time animationrange.start 
	(
		b.pos = [0,0,0]
	)
	at time ((animationrange.start + animationrange.end)/2)
	(
		b.pos = [50,0,50]
	)
	at time animationrange.end 
	(
		b.pos = [100,0,0]
	)
)

 

2. Use default new key tangent type:

 

delete objects
b = box isselected:on

def_in = BezierDefaultParams.inTangentType 
def_out = BezierDefaultParams.outTangentType

BezierDefaultParams.inTangentType = #linear
BezierDefaultParams.outTangentType = #linear

--BezierDefaultParams.inTangentType = #flat
--BezierDefaultParams.outTangentType = #flat

with animate on
(
	at time animationrange.start 
	(
		b.pos = [0,0,0]
	)
	at time ((animationrange.start + animationrange.end)/2)
	(
		b.pos = [50,0,50]
	)
	at time animationrange.end 
	(
		b.pos = [100,0,0]
	)
)

BezierDefaultParams.inTangentType = def_in
BezierDefaultParams.outTangentType = def_out

 

3. Set key's tangents:

 

delete objects
b = box isselected:on

with animate on
(
	at time animationrange.start 
	(
		b.pos = [0,0,0]
	)
	at time ((animationrange.start + animationrange.end)/2)
	(
		b.pos = [50,0,50]
	)
	at time animationrange.end 
	(
		b.pos = [100,0,0]
	)
)

p = b.pos.controller
for k=1 to 3 do
(
	for key in p[k].keys do
	(
		key.intangenttype = #linear
		key.outtangenttype = #linear
	)
)

 

 

Here is a homework: 

Find another mxs built-in methods to do the same as in the solution #2

😉

 

Message 3 of 3

DerSekki
Explorer
Explorer

I used the first solution and it works like a charm. Unfortunately, im not a max scripter and i feel like documentation is close to non-existent (atleast, if im trying to google for it). It's probably just me and my searching skills.

 

Thank you. 🙂

0 Likes