RE: Scripting Animation Layers, Part2

Date : Tue, 17 Apr 2007 19:09:29 +0100
To : <XSI(at)Softimage.COM>
From : "Brent McPherson" <brentmc(at)Softimage.COM>
Subject : RE: Scripting Animation Layers, Part2
Good news Andre.

We sort of knew scripting in this area would be a little ropey in 6.0 so I'm glad you managed to get something working. Feel free to also log any suggestions you think would make life easier on the scripting front for this stuff.
--
Brent

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of André Adam
Sent: Tuesday, April 17, 2007 4:39 PM
To: XSI(at)Softimage.COM
Subject: Re: Scripting Animation Layers, Part2

Heya, I got something working, sneaking through the backdoor (iterating 
the mixerclips instead of the tracks). I also logged a bug for the 
missing Type property for animation layer tracks. If I'm not the only 
one who wants to match Anim Layer IDs with Anim Layer names, this works:

Cheers!

    -André


function fGetAnimLayers(oModel){
  var aAnimLayers = new Array();
  var eClips = new Enumerator(oModel.Mixer.Clips);
  while(!eClips.atEnd()){
    if(eClips.item().Type == "mixerlayerclip"){
      aAnimLayers.push(eClips.item().Name);
      aAnimLayers.push(eClips.item().Owners(0).Parameters("layer").Value);
    }
    eClips.moveNext();
  }
  return aAnimLayers;
}
 

var oModel = Selection(0).Model;
if(oModel.HasMixer()){
  var aAnimLayers = fGetAnimLayers(oModel);
  if(aAnimLayers.length > 0){
    for(var i=0; i<aAnimLayers.length; i+=2){
      LogMessage(aAnimLayers[i] + ": " + aAnimLayers[i+1]);
    }
  }
  else{
    LogMessage("No Anim Layers!");
  }
}
else{
  LogMessage("No Mixer!");
}


Brent McPherson wrote:
> Hi Andre,
>
> The commands below are mainly there for the animation layer editor panel.
>
> Unfortunately, we didn't have time in 6.0 to add new APIs for animation layers but the existing mixer SDK should pretty much work with the new layer tracks/clips. So, if something is missing or doesn't work you should send in bug requests as usual.
>
> Thanks.
> --
> Brent
>
> -----Original Message-----
> From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of André Adam
> Sent: Tuesday, April 17, 2007 9:00 AM
> To: xsi(at)Softimage.COM
> Subject: Scripting Animation Layers, Part2
>
> //Start rant
>
> Hi, next try to do something useful with animation layers via scripting. 
> Did I miss something or are there really only these five commands to 
> deal with them:
>
> GetCurrentAnimationLayer - Returns an integer
> GetNumberOfAnimationLayers - Returns an integer
> AddAnimationLayer - Does just that
> DeleteAnimationLayer - Reference to Layer via - guess what - an integer
> DuplicateAnimationLayer - Reference again via an integer
>
> Of course, what I really need is decent OM access, however, I certainly 
> could live with commands *if there was any way to reference animation 
> layers by name*. I can't even seem to find out the name of the current 
> animation layer. And, just to really make my day, I can't even move 
> through the Mixer and pick up the required information from there, 
> because Animation Layer Tracks are missing the Type property. Any 
> attempt to filter out the layer tracks therefore crashes right away. 
> (This is a bug, isn't it? I don't even want to think what this means for 
> my Mixer tools in general...)
>
> //End of rant
>
> On a more constructive note, is there anyone who had success in 
> associating layer names with layer indices and willing to share the 
> recipe? I guess I could filter the AL tracks through error handling, 
> something like
>
> try{
>     LogMessage(oTrack.Type);
> }
> catch(oError){
>     LogMessage("Oups, we seem to have found an animation layer...");
> }
>
> but hey, there must be a better way...
>
> Thanks for any piece of information on this topic. Cheers!
>
>     -André

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.