Re: [ scripting ] Filter "NodeAnimatedParameters" to be only translate

Date : Tue, 16 Oct 2007 08:49:09 +0200
To : XSI(at)Softimage.COM
From : "Stefan Andersson" <sanders3d(at)gmail.com>
Subject : Re: [ scripting ] Filter "NodeAnimatedParameters" to be only translate
Ah, make tuples *before* actually doing something. I had a little
thinker about this before also. But wouldn't memory be an issue here
if the code (in the PPG) first make 4 tuplets and then store that into
memory...

I guess I have to try first.

thanks for all the help.

regards
stefan


On 10/15/07, Nicolas Langlois <nicolasl(at)buzzimage.com> wrote:
> Stefan,
>
> All right now that's clearer. What you're trying is to do each object
> one after the other so it's not on the keys or on the parameters that
> you need to iterate.
>
> sels = xsi.Selection
> goodSel = []
>
> # Get all the objects that have an Fcurve to anymate any of their pos
> for sel in sels:
>         if sel.NodeAnimatedParameters(c.siFCurveSource)
>                 for oFCurveAnimatedParam in oFCurveAnimatedParams:
>                         if "pos" in oFCurveAnimatedParam.Name:
>                                 goodSel.append(oFCurveAnimatedParam)
>
> # Now offset them each after the other - Assuming you have only one pos param animated per object
> for i in range(len(goodSel)):
>         oFCurve = goodSel[i].Source
>         oRange = oFCurve.GetKeysBetween(oIn, oOut)
>         oFCurve.OffsetKeys(oRange, oTimeOffset * i)
>
>
>
> Hope it helps!
>
> Nicolas Langlois
> Senior/Lead Rigger/TD
> Buzz Image
>
>
>
> Stefan Andersson wrote:
> > Hi Nicolas,
> > The reason why I would like to isolate different SRT's is to give the
> > user some flexibility when using my plugin.
> >
> > Here is how it works now.
> >
> > 1.) You create 100 cubes and place them as a grid (think tiles in a bathroom)
> > 2.) You set a keyframe in rotation at frame 1 (on all of them)
> > 3.) You rotate them in X 360 degrees and set that keyframe on frame 5
> > 4.) you select them in the order that you want them to offset the animation
> > 5.) you run the script (or in my case they have a menu and a GUI with options)
> >
> > could look like this
> > http://sanders3d.googlepages.com/tiles.mov
> >
> > Now I would like the user to be able to chose if he/she wants to do
> > the offset only on rotation, scaling, translation or visibility (those
> > four are the most common ones you use in this type of animation).
> >
> > Anyhow, perhaps that will clear up what I want to do :)
> >
> > regards
> > stefan
> >
> >
> > On 10/15/07, Nicolas Langlois <nicolasl(at)buzzimage.com> wrote:
> >
> >> Stefan,
> >>
> >> I'm not sure what you're trying to do but if you're trying to to
> >> gradually offset each key of the fCurve (so that the offset is getting
> >> more and more intense, like your first script seems to imply by -
> >> "oFCurve.OffsetKeys(oRange, oTimeOffset * i" ), here's something you
> >> should look into:
> >>
> >> xsi.Selection(i).NodeAnimatedParameters(c.siFCurveSource)
> >>         for oObj in oFCurveAnimatedParams:
> >>                 if "pos" in oObj.Name:
> >>                         oFCurve = oObj.Source
> >>                         oRange = oFCurve.GetKeysBetween(oIn, oOut)
> >>                         # Get all keys of the fcurve and offset them
> >>                         oKeys = oFCurve.Keys
> >>                         for i in range(len(oKeys)):
> >>                                 # To offset them more and more
> >>                                 oKeys(i).Time.Value = oTimeOffset * i
> >>                                 # To offset them all the same value
> >>                                 #oKeys(i).Time.Value = oTimeOffset
> >>
> >>
> >> Is this what you're looking for?
> >>
> >>
> >> Nicolas Langlois
> >> Senior/Lead Rigger/TD
> >> Buzz Image
> >>
> >>
> >>
> >> Stefan Andersson wrote:
> >>
> >>> ok... this:
> >>> ------
> >>> for i in range(oSel):
> >>>       oFAP =  xsi.Selection(i).NodeAnimatedParameters(c.siFCurveSource)
> >>>       for oObj in oFAP:
> >>>               xsi.LogMessage(oObj)
> >>> ------
> >>> gives me the name of the object and the posy, posz etc.
> >>>
> >>> This gives me nothing
> >>> ------
> >>> for i in range(oSel):
> >>>       oFAP =  xsi.Selection(i).NodeAnimatedParameters(c.siFCurveSource)
> >>>       for oObj in oFAP:
> >>>               if 'rot' in oObj.Name:
> >>>                       xsi.LogMessage("yes")
> >>> ------
> >>> This gives me a callback of 'X' 'Y' 'Z'
> >>> ------
> >>> for i in range(oSel):
> >>>       oFAP =  xsi.Selection(i).NodeAnimatedParameters(c.siFCurveSource)
> >>>       for oObj in oFAP:
> >>>               xsi.LogMessage(oObj.Name)
> >>> ----
> >>>
> >>> Anyone has any ideas?? :)
> >>>
> >>> regards
> >>> stfean
> >>>
> >>>
> >>> On 10/15/07, Stefan Andersson <sanders3d(at)gmail.com> wrote:
> >>>
> >>>
> >>>> Hi Nicolas,
> >>>>
> >>>> kind of lame that I didn't see that at first :)
> >>>>
> >>>> However, I'm still stuck, perhaps my method should be revamped.
> >>>> Because the function siFCurveSource gives you a boolean number if a
> >>>> animation curve exists or not. And it still would do a offset on all
> >>>> of the keyframes from the function OffsetKeys
> >>>>
> >>>> hmm... I might need to rethink it from the start I think.
> >>>>
> >>>> regards
> >>>> stefan
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> On 10/15/07, Nicolas Langlois <nicolasl(at)buzzimage.com> wrote:
> >>>>
> >>>>
> >>>>> Stephan,
> >>>>>
> >>>>> It's not "siFCurveSource" that you need to check to see if it's pos or
> >>>>> rot or else, it's "oObj".
> >>>>>
> >>>>> in your script do this:
> >>>>>
> >>>>> #--- start of python script
> >>>>>
> >>>>> import win32com.client
> >>>>> from win32com.client import constants as c
> >>>>>
> >>>>> xsi = Application
> >>>>>
> >>>>> oIn = 1
> >>>>> oOut = 100
> >>>>> oTimeOffset = 2
> >>>>>
> >>>>> oSel = xsi.Selection.Count
> >>>>>
> >>>>> for i in range(oSel):
> >>>>>         oFCurveAnimatedParams =
> >>>>> xsi.Selection(i).NodeAnimatedParameters(c.siFCurveSource)
> >>>>>         for oObj in oFCurveAnimatedParams:
> >>>>>                 if "pos" in oObj.Name: # THIS IS WHAT YOUR LOOKING FOR I THINK
> >>>>>                         oFCurve = oObj.Source
> >>>>>                         oRange = oFCurve.GetKeysBetween(oIn, oOut)
> >>>>>                         oFCurve.OffsetKeys(oRange, oTimeOffset * i)
> >>>>>
> >>>>> #--- end of python script
> >>>>>
> >>>>> Nicolas Langlois
> >>>>> Senior/Lead Rigger/TD
> >>>>> Buzz Image
> >>>>>
> >>>>>
> >>>>>
> >>>>> Stefan Andersson wrote:
> >>>>>
> >>>>>
> >>>>>> Hi All,
> >>>>>>
> >>>>>> I'm working (again) on this offset plugin. Thanks to André I now have
> >>>>>> a much faster plugin using the xsi model. Though, now I would like to
> >>>>>> filter out what's being selected or offset. The working base code I
> >>>>>> have now is:
> >>>>>>
> >>>>>> ( can also be downloaded at http://sanders3d.googlepages.com/ )
> >>>>>>
> >>>>>> #--- start of python script
> >>>>>>
> >>>>>> import win32com.client
> >>>>>> from win32com.client import constants as c
> >>>>>>
> >>>>>> xsi = Application
> >>>>>>
> >>>>>> oIn = 1
> >>>>>> oOut = 100
> >>>>>> oTimeOffset = 2
> >>>>>>
> >>>>>> oSel = xsi.Selection.Count
> >>>>>>
> >>>>>> for i in range(oSel):
> >>>>>>       oFCurveAnimatedParams =
> >>>>>> xsi.Selection(i).NodeAnimatedParameters(c.siFCurveSource)
> >>>>>>       for oObj in oFCurveAnimatedParams:
> >>>>>>               oFCurve = oObj.Source
> >>>>>>               oRange = oFCurve.GetKeysBetween(oIn, oOut)
> >>>>>>               oFCurve.OffsetKeys(oRange, oTimeOffset * i)
> >>>>>>
> >>>>>> #--- end of python script
> >>>>>>
> >>>>>> I would like to filter the "siFCurveSource" to only select
> >>>>>> translation, rotation, etc. I've tried to look in the SDK docs if
> >>>>>> something like "siFCurveSource.posx" or anything like that exists.
> >>>>>> I don't know... learning as I go at least :) Anyone up for making any pointers?
> >>>>>>
> >>>>>> regards
> >>>>>> stefan andersson
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>> ---
> >>>>> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> >>>>> unsubscribe xsi
> >>>>>
> >>>>>
> >>>>>
> >>>> --
> >>>> __________________________________________
> >>>> Pixel Abuser (at) http://www.swiss.se/
> >>>> Blog (at) http://sanders3d.blogspot.com/
> >>>> Web (at) http://sanders3d.googlepages.com/
> >>>> work e.mail: stefan [at] swiss.se
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >> ---
> >> 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
>


-- 
__________________________________________
Pixel Abuser (at) http://www.swiss.se/
Blog (at) http://sanders3d.blogspot.com/
Web (at) http://sanders3d.googlepages.com/
work e.mail: stefan [at] swiss.se

---
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.