Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 11-09-2015 , 05:33 AM
Registered User
Join Date: Sep 2015
Posts: 2

Script Request, assistance please :)

Hello all,

I am new to simply Maya but I am an avid Maya user and scripting is not my main key point so I need expert's help. My problem is the following, I have a scene where I have a bunch of objects (300 to be precise) animating and flying off into the air (they were naprticles that were made into animated geometry object using a script), the visibilty on each object is key off when they are not yet emited and turned on when they are emitted, my workflow is exporting as obj sequence and comping them in after effects using E3D.

Here's the tricky part E3D does not support keyed visibility I have managed to think of a detour and that is to animate the scale from (0,0,0) when they are not emitted to 1 when they start to emitte, but I have over 300 object each one appearing at a certain time linked to the keyed visibility attribute.

My request can someone help me script a MEL or Python script that can link the scale of any selected object to the visibility, example if visibility = 0 then scale =0,0,0 else scale = 1,1,1.


Thank you very much.user added image

# 2 11-09-2015 , 04:55 PM
Registered User
Join Date: Sep 2015
Posts: 2
Hello Guys sorry it was a silly question I just made the scales = vibility hehehe in an expression a made it accessible to all selected objects, it's very silly.

# 3 11-09-2015 , 05:25 PM
David's Avatar
SM Tea Boy
Join Date: Apr 2002
Location: Prague
Posts: 3,228
Glad you worked it out hopefully it will help out someone else user added image

Welcome to SimplyMaya
Dave


From a readers' Q and A column in TV GUIDE: "If we get involved in a nuclear war, would the electromagnetic pulses from exploding bombs damage my videotapes?"
# 4 25-01-2016 , 07:13 PM
Registered User
Join Date: Jan 2016
Posts: 1

Hello Guys sorry it was a silly question I just made the scales = vibility hehehe in an expression a made it accessible to all selected objects, it's very silly.

Hello! I'm super curious about this because I'm running into the same challenge as you, only I feel like you have even more scripting knowledge than I do! Your solution seems like it would work for my purposes as well - what did your expression look like in the end?

# 5 26-01-2016 , 04:47 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
You don't even need an expression - using node connections would provide faster frame rates. The script below will connect scale X, Y and Z to the visibility attribute. Therefore when the object is visible the scale will be 1, and when it's invisible, it will be zero. The extra code simply removes static channels (for example if you're keying with "s" instead of "W"), and repeats the connections for every selected object.

Select all of your objects and run the following in the mel tab in the script editor:

Code:
string $sel[] = `ls -sl`;

for ($obj in $sel)
{
    delete -staticChannels -unitlessAnimationCurves false -hierarchy 0 -controlPoints 0 -shape 0 $obj;    // remove static channels
    connectAttr ($obj + ".visibility") ($obj + ".scaleX");
    connectAttr ($obj + ".visibility") ($obj + ".scaleY");
    connectAttr ($obj + ".visibility") ($obj + ".scaleZ");
}


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads