CGTalk > General Techniques > Character Rigging
To minimize the ads you see on this page create a CGTalk account and log in HERE
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-06-2011, 11:01 PM   #1
dande
New Member
portfolio
Dan Deery
Co. Mayo, Ireland
 
Join Date: Sep 2009
Posts: 15
Max Rigging the number of frames to a Custom Attribute

I have a general rigging question. I have a number of rigged objects connected to a path constraint. I need to change the speed of these objects from time to time. I can easily do this by setting the number of frames in the track bar. This is time consuming. I would like to be able to set the frame length of these objects through a custom attribute. How can I access the number of frames through rigging

Thanks
 
Old 02-11-2011, 09:24 PM   #2
Pacermike
Know-it-All
 
Pacermike's Avatar
portfolio
Andy
Animator
SuperVillain Studios
Orange, USA
 
Join Date: Feb 2009
Posts: 311
Is this right?

Hey, not sure if this is what you meant but here's some Custom Attributes will make a spinner that can move the end key frame of an object animated along a path constraint. The way it's written right now would only work on an object named box02 and would only move the second frame on a path constrained object. You could change the script to do whatever you wanted it to though. I attached a max file (made in Max 9. Ignore the "missing DLLs" error that pops up, its just a bunch of work plugins). Just select the box and slide the spinner in the End Frame rollout under Box02's Modify tab.

Code:
frameCA = attributes Frame_Mover ( parameters main rollout:spinnersRol ( spinOne type:#integer ui:spn_one ) rollout spinnersRol "End Frame" ( spinner spn_one type:#integer fn fart here = ( moveKey $box02.controller[1][2][1].controller 2 ((here.frame)-(getKeyTime $box02.controller[1][2][1].controller 2)) ) on spn_one changed val do fart ((normTime val)/100) ) )


Hope this helps.
Attached Files
File Type: zip frameTest scene.zip (16.5 KB, 5 views)
 
Old 02-12-2011, 11:27 AM   #3
dande
New Member
portfolio
Dan Deery
Co. Mayo, Ireland
 
Join Date: Sep 2009
Posts: 15
That exactly what I need

Thanks.

Thats exactly what I'm looking for. I can change the code to suit my object. But where do I put the code?
 
Old 02-13-2011, 05:07 PM   #4
dande
New Member
portfolio
Dan Deery
Co. Mayo, Ireland
 
Join Date: Sep 2009
Posts: 15
Thanks Thats exactly what I'm looking for

Thanks. Thats exactly what I'm looking for. I can change the code to suit the objects in my scene. But where should I put the code?

Thanks again for your help
 
Old 02-13-2011, 07:28 PM   #5
Pacermike
Know-it-All
 
Pacermike's Avatar
portfolio
Andy
Animator
SuperVillain Studios
Orange, USA
 
Join Date: Feb 2009
Posts: 311
You just add the code to the actual object. In the test scene file the object was Box02. So in the Listener or in a new script window evaluate the first code I gave you which gives "frameCA" a definition.

Then evaluate this in the Listener:

Code:
custAttributes.add $Box02 frameCA

This will add "frameCA" to the Box02 example object. Once the attribute definition is on the object you can redefine it to make changes to the code like this:

Code:
-- frameCA = /I comment out the first line so it doesn't evaluate/ attributes Frame_Mover redefine:frameCA -- /This line tells it to redefine the definition/ ( -- /Then make whatever changes to the body of the code../ )

When you start really getting in to this go to the Maxscript Reference under the Help menu and look up "Custom Attribute". Read all the help files a few times and eventually it'll start making sense.
 
Old 02-13-2011, 07:59 PM   #6
dande
New Member
portfolio
Dan Deery
Co. Mayo, Ireland
 
Join Date: Sep 2009
Posts: 15
Thanks again

Thanks again for you help. I really appreciate it.
 
Old 02-14-2011, 12:26 PM   #7
dande
New Member
portfolio
Dan Deery
Co. Mayo, Ireland
 
Join Date: Sep 2009
Posts: 15
Sorry to bother you again

I have created a scene similar to yours. Added a path constraint to the box. Then added the code as you described. But when I set the number of frames I get the following error

-- Error occurred in fart()
-- Frame:
-- here: 1000f
-- called in spn_one.changed()
-- Frame:
-- val: 100
>> MAXScript Rollout Handler Exception: -- Unknown property: "controller" in undefined <<

I've been playing about with it and I can't fix it.

Thanks
 
Old 02-14-2011, 06:41 PM   #8
Pacermike
Know-it-All
 
Pacermike's Avatar
portfolio
Andy
Animator
SuperVillain Studios
Orange, USA
 
Join Date: Feb 2009
Posts: 311
Hehe, "Error occurred in fart()".

My guess is it has something to do with "$box02.controller[1][2][1].controller". Controller[1][2][1].controller is looking for the first controller "[1]" which is a Position List. Nested in that Position List is "[2]", the Path Constraint. Within the Path Constraint are four float values and the first one, "[1]" is the Percent Float. The controller on the Percent Float holds the animated Key property that we're trying to access and manipulate through the script. So we get, $box02.controller[1][2][1].controller. This is a very specific way of accessing the key on an object so if anything is out of order the script won't know what's it's looking for and will come back as undefined.

You want to save the file as an archive (.zip) and attach it? I can take a look and see if I can tell what's breaking it.

Also, try this:

Code:
frameCA = attributes Frame_Mover ( parameters main rollout:spinnersRol ( spinOne type:#integer ui:spn_one ) rollout spinnersRol "End Frame" ( spinner spn_one type:#integer range: [1, ((animationRange.end).frame), 0] fn fart here = ( local zoot = exprForMAXObject (custAttributes.getOwner this) explicitNames:true local toot = execute zoot moveKey toot.controller[1][2][1].controller 2 ((here.frame)-(getKeyTime toot.controller[1][2][1].controller 2)) ) on spn_one changed val do fart ((normTime val)/(abs animationRange.start + abs animationRange.end).frame) ) )


I changed it so that the spinner will adjust to the length of the animation timeline. I also changed it so that the name of the object doesn't matter anymore. "exprForMAXObject (custAttributes.getOwner this) explicitNames:true" finds the name of the object that has the Custom Attribute on it, so if a name mismatch was causing your crash before this should fix that. Let me know if it works out.

Last edited by Pacermike : 02-14-2011 at 09:05 PM.
 
Old 02-17-2011, 03:25 PM   #9
dande
New Member
portfolio
Dan Deery
Co. Mayo, Ireland
 
Join Date: Sep 2009
Posts: 15
Got it working

Thanks for your help I got it working. The error problem was that even if I changed the name of the object to Box01 in the code and ran the code the controller error was being caused by Max looking for your box02. So reading through your information I changed the code to the following and it now works really well

"frameCA = attributes Frame_Mover
(
parameters main rollout:spinnersRol
(
spinOne type:#integer ui:spn_one
)

rollout spinnersRol "Animation"
(
spinner spn_one type:#integer range: [1, ((animationRange.end).frame), 0]

fn fart here =
(
moveKey $box01.controller[1][2][1].controller 2 ((here.frame)-(getKeyTime $box01.controller[1][2][1].controller 2))
)

on spn_one changed val do fart ((normTime val)/100)
)
)

custAttributes.add $box01 frameCA"
 
Old 02-17-2011, 06:26 PM   #10
Pacermike
Know-it-All
 
Pacermike's Avatar
portfolio
Andy
Animator
SuperVillain Studios
Orange, USA
 
Join Date: Feb 2009
Posts: 311
Cool, man. Glad to hear it!
 
Old 02-17-2011, 06:26 PM   #11
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:14 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.