<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Selected Keys? Move Keys?]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 21/02/2011 at 02:04, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Trying to find a way to identify selected timeline keys and move them</p>
<p dir="auto">ie</p>
<p dir="auto">3 items<br />
3 tracks<br />
select a range of  keys for all three items<br />
move keys on the tracks by differing amounts</p>
<p dir="auto">essentially running c4d.CallCommand(465001216) - the Move Scale Selected Keyframe command<br />
on each track<br />
with different MOVE values</p>
<p dir="auto">any help appreciated</p>
<p dir="auto">(thanks to Scott A so far)</p>
]]></description><link>http://developers.maxon.net/forum/topic/5517/5536_selected-keys-move-keys</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 15:43:43 GMT</lastBuildDate><atom:link href="http://developers.maxon.net/forum/topic/5517.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 May 2018 17:51:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:37 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 06/03/2011 at 11:09, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">cheers Nux</p>
]]></description><link>http://developers.maxon.net/forum/post/25703</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25703</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:37 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:37 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 06/03/2011 at 10:29, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Well, works fine. If you want potential increament for eg. you need to calculate something with the offset value. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";-)" alt="😉" /></p>
]]></description><link>http://developers.maxon.net/forum/post/25702</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25702</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:37 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:36 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 06/03/2011 at 08:05, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Any feedback on programing 'form' would be appreciated.</p>
<p dir="auto">Think it would be useful to have a couple more transformations<br />
Stagger2 - enter total stagger length - x frames (rather than current overlap in frames)<br />
Accelerate - gradually space out over x frames<br />
Decelerate - reverse above<br />
Stack - thats essentially stagger with no overlap?</p>
]]></description><link>http://developers.maxon.net/forum/post/25701</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25701</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:36 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 03/03/2011 at 06:11, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">And this is where I'm at so far</p>
<p dir="auto">Ignore some Print items - just for console checks</p>
<p dir="auto">Still trying to make it modular<br />
ie have a function for each type of key transform - (just stagger in this one)<br />
appreciate any advice on good/bad code form</p>
<p dir="auto">added gui to take offset<br />
count selected objects - need more than 2<br />
and now first object doesnt get offset (its popped off array)</p>
<pre><code>#####################################
def MoveSelectedKeys(op,offset,timeln = 1) :    # offset in frames
    import c4d
  
    if (not op) or (not offset) : return False
  
    if timeln == 1: timeln = c4d.NBIT_TL1_SELECT
    elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT
    elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT
    elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT
    else:
        import math
        timeln = math.fmod(timeln,4)
  
    doc = op.GetDocument()
  
    track = op.GetFirstCTrack()
    if not track: return False
  
    fps = float(doc.GetFps())
  
    while track:
        curve = track.GetCurve()
        cnt = curve.GetKeyCount()
        for i in xrange(cnt) :
            key = curve.GetKey(i)
            if key.GetNBit(int(timeln)) == True:
                tme = key.GetTime()
                key.SetTime(curve,c4d.BaseTime(offset/fps+tme.Get()))
        track = track.GetNext()
    c4d.EventAdd(c4d.MSG_UPDATE)
  
    return True
#####################################
def GetLastSelectedKey(track, timeln = 1) :
    import c4d
  
    if timeln == 1: timeln = c4d.NBIT_TL1_SELECT
    elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT
    elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT
    elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT
    else:
        import math
        timeln = math.fmod(timeln,4)
  
    curve = track.GetCurve()
    cnt = curve.GetKeyCount()
  
    for i in xrange(cnt) :
        key = curve.GetKey(cnt-i-1)
        if key.GetNBit(int(timeln)) == True:
            return key  
####################################MINE
def GetFirstSelectedKey(track, timeln = 1) :
    import c4d
  
  
    if timeln == 1: timeln = c4d.NBIT_TL1_SELECT
    elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT
    elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT
    elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT
    else:
        import math
        timeln = math.fmod(timeln,4)
  
    curve = track.GetCurve()
    cnt = curve.GetKeyCount()
    key = curve.GetKey(0)
  
    if key.GetNBit(int(timeln)) == True:
        return key 
#####################################
def GetHNext(op) :
    if not op: return
    if op.GetDown() : return op.GetDown()
    while not op.GetNext() and op.GetUp() :
        op = op.GetUp()
    return op.GetNext()
#####################################
def GetActiveObjects(doc) :
    import c4d
    lst = list()
    op = doc.GetFirstObject()
    while op:
        if op.GetBit(c4d.BIT_ACTIVE) == True: lst.append(op)
        op = GetHNext(op)
    return lst
#####################################MINE
def Stagger(doc,op,lst,keylast,overlap) :
    import c4d
    print "Length of list before pop", len(lst) 
    lst.pop(0)  #remove the first object as its not moved
    op = lst[0] #get fist active object again, less original first object
    print "Length of list after pop", len(lst) 
  
 
    offset = keylast.GetTime().GetFrame(doc.GetFps())-overlap
    for i in xrange(len(lst)) : #increment through allthe objects selected
        doc.AddUndo(c4d.UNDOTYPE_CHANGE,op)
        MoveSelectedKeys(op,offset) #moves all the selected keys on a track
        keylast = GetLastSelectedKey(op.GetFirstCTrack())
  
  
      
        if not keylast: offset = 0
        # the original cal moved everything # else: offset = key.GetTime().GetFrame(doc.GetFps())-overlap
        else: 
            print "OS1", offset
            offset = keylast.GetTime().GetFrame(doc.GetFps())-overlap
            print "OS2", offset
        # object namecheck # print op.GetName()
        if  i+1 &lt; len(lst) : # +1 stops index going out of range ie more objects than listed
            op = lst[i+1]# ok to get next object in list
  
    return 
#####################################
def main() :
    import c4d
    from c4d import documents
    from c4d import gui
    
    c4d.CallCommand(1024314); # clear the python console
 
    # get a value form the user
    guival = gui.InputDialog("Enter a value &lt; your max keyspan","10")
    print "Dialog Value =",guival
    overlap = int(guival)   
    doc = documents.GetActiveDocument()
    doc.StartUndo()
  
    lst = GetActiveObjects(doc) #get selected objects
  
    print "List Length = ", len(lst) 
    if len(lst)&lt;=1:
        c4d.gui.MessageDialog("You need to select at least two objects") 
        return False #leave if not enough objects selected
 
    op = lst[0] #get fist active object
  
  
    keyfirst = GetFirstSelectedKey(op.GetFirstCTrack())
    keylast = GetLastSelectedKey(op.GetFirstCTrack())
    
  
    keyfirstval = keyfirst.GetTime().GetFrame(doc.GetFps())
    keylastval = keylast.GetTime().GetFrame(doc.GetFps())
    keyspanval = keylastval - keyfirstval
   
    print "Selected Keyspan 1st track = ", keyspanval
    print "Keytime of start key = ", keyfirstval
    print "Keytime of end key = ", keylastval
    
 
   
    if not keylast: offset = 0
    ##### else do the stagger
    else: Stagger(doc,op,lst,keylast,overlap) 
     
    doc.EndUndo()
  
if __name__=='__main__':
    main()
  

</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/25700</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25700</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:36 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 02/03/2011 at 03:22, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">the list only gets appended if op is selected. <img src="smileys/smiley2.gif" alt="" class=" img-fluid img-markdown" /></p>
]]></description><link>http://developers.maxon.net/forum/post/25699</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25699</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:36 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 02/03/2011 at 03:03, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi Nux</p>
<p dir="auto">nope, not that - must be forum paste incorrect<br />
indent is as your example</p>
<p dir="auto">appreciate you can't test at moment</p>
<p dir="auto">I think its to do with this function setting op to the first object in doc<br />
if nothing selected<br />
that way op is never NULL <br />
#####################################<br />
def GetActiveObjects(doc) :<br />
    import c4d<br />
    lst = list()<br />
    op = doc.GetFirstObject()<br />
    while op:<br />
        if op.GetBit(c4d.BIT_ACTIVE) == True: lst.append(op)<br />
        op = GetHNext(op)<br />
    return lst<br />
#####################################</p>
]]></description><link>http://developers.maxon.net/forum/post/25698</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25698</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:36 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 02/03/2011 at 02:37, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Dunnoo .. Gonna test this this weekend. Maybe it's because op = lst[0] ist not in the right column ?</p>
<pre><code>  lst = GetActiveObjects(doc)
  op = lst[0] ## here
    if not op:
        gui.MessageDialog("No objects selected") 
        return False #leave the script if not an object
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/25697</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25697</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 02/03/2011 at 01:03, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Can anyone tell me why this message <br />
doesn't pop up if NO object is selected using the function from the code above?</p>
<p dir="auto">lst = GetActiveObjects(doc)<br />
    op = lst[0]<br />
    if not op:<br />
        gui.MessageDialog("No objects selected") <br />
        return False #leave the script if not an object</p>
]]></description><link>http://developers.maxon.net/forum/post/25696</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25696</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 01/03/2011 at 07:21, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">I am sorry, I may can go to my pc this weekend, but not earlier.</p>
<p dir="auto">Does the Console tell you this ? O.o</p>
<p dir="auto">If A function calls itself, everything starts again. But you may have changed some values before. (Here the timeln variable)</p>
]]></description><link>http://developers.maxon.net/forum/post/25695</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25695</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 01/03/2011 at 00:42, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Making an effort to understand what I'm seeing</p>
<p dir="auto">Line 14 function call within itself - seems incorrect?<br />
       <br />
MoveSelectedKeys(op,offset,timeln)</p>
]]></description><link>http://developers.maxon.net/forum/post/25694</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25694</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 27/02/2011 at 08:05, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Trying to move this on in a more modular way<br />
ie have a  function for each transformation on selected keys</p>
<p dir="auto">just wondered if I was heading in the right direction???<br />
(ignore print checkpoints just for testing)</p>
<p dir="auto">Next objective to 'nudge' everything back<br />
as 'everything' gets moved over by staggering process<br />
ie first track shouldnt move - everything else - stagger</p>
<pre><code>#####################################
Updated version in later post
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/25693</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25693</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 27/02/2011 at 03:10, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Using</p>
<pre><code>if i+1 &lt; len(lst) :
	op = lst[i+1]
</code></pre>
<p dir="auto">got rid of the index error</p>
<p dir="auto">As far as writing a plugin. A bit beyond me at present, probably best to learn from your foundation work here Nux.</p>
]]></description><link>http://developers.maxon.net/forum/post/25692</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25692</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 26/02/2011 at 13:22, <strong>xxxxxxxx</strong> wrote:</em></p>
<blockquote>
<p dir="auto"><strong>Originally posted by xxxxxxxx</strong></p>
<p dir="auto">line 103 <br />
op=list[i+1]<br />
is throwing an error<br />
index out of range</p>
</blockquote>
<p dir="auto">Do you recieve that message every time ? It didn't appear when I was using the Script.</p>
<blockquote>
<p dir="auto">I guess this is just incrementing one object too many? at the end of the selected objects</p>
</blockquote>
<p dir="auto">Shouldnt. 'op' is already the object with index 0, and 'i' starts with '0', so the next object for 'op' in the first iteration should be 1 =&gt; 'i+1'<br />
But .. Hm, very bizarre. I didn't recieve that error, but as I think about it, that error MUST occure at the end of the loop.<br />
Try it like this and tell me if the problen still exists:</p>
<pre><code>  
op = lst[i+1]   
if not op: break # Hopefully there is a 'break' expression for 'for'-loops. If not try something that stops the loop   
</code></pre>
<blockquote>
<p dir="auto">stagger  - by total time - total time over which to stagger all frames<br />
stagger exponentially large to small<br />
stagger exponentially small to large<br />
etc etc</p>
</blockquote>
<p dir="auto">Why not writing a Plugin ? <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";-)" alt="😉" /></p>
<p dir="auto">cheers, nux</p>
]]></description><link>http://developers.maxon.net/forum/post/25691</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25691</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 26/02/2011 at 12:08, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hey Nux95</p>
<p dir="auto">This is just great</p>
<p dir="auto">And there's so much useful stuff here for reference<br />
It's really appreciated  - many thanks</p>
<p dir="auto">line 103 <br />
op=list[i+1]<br />
is throwing an error<br />
index out of range</p>
<p dir="auto">I guess this is just incrementing one object too many? at the end of the selected objects</p>
<p dir="auto">Not wanting to take anything away from what you've done here - far beyond the call of duty <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
I think it would be nice to have the 'processing' part of the script possibly<br />
in a function</p>
<p dir="auto">ie release a collection of key manipulating scripts - by just changing the function</p>
<p dir="auto">stagger - by offset - as we have now<br />
stagger  - by total time - total time over which to stagger all frames<br />
stagger exponentially large to small<br />
stagger exponentially small to large<br />
etc etc</p>
<p dir="auto">cheers again</p>
]]></description><link>http://developers.maxon.net/forum/post/25690</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25690</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:35 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 26/02/2011 at 05:23, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Ah, you mean the 2nd Cube should start moving when the 1st one finished ?<br />
That shouldn't be a problem.<br />
I'll be back in a minute with a function doing this.</p>
<p dir="auto">cheers</p>
<p dir="auto">PS: Do still only the selected keys need to be moved ?</p>
<p dir="auto">//So, this is a bit more complex than i thought. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f602.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--joy" style="height:23px;width:auto;vertical-align:middle" title=":joy:" alt="😂" /><br />
But it works fine <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<pre><code>import c4d  
from c4d import documents  
  
overlap = 20    ## Change this to the Frame you want to let the keys beeing overlapped  
  
def MoveSelectedKeys(op,offset,timeln = 1) :    # offset in frames  
  import c4d  
  
  if (not op) or (not offset) : return False  
  
  if timeln == 1: timeln = c4d.NBIT_TL1_SELECT  
  elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT  
  elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT  
  elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT  
  else:  
      import math  
      timeln = math.fmod(timeln,4)  
      MoveSelectedKeys(op,offset,timeln)  
  
  doc = op.GetDocument()  
  
  track = op.GetFirstCTrack()  
  if not track: return False  
  
  fps = float(doc.GetFps())  
  
  while track:  
      curve = track.GetCurve()  
      cnt = curve.GetKeyCount()  
      for i in xrange(cnt) :  
          key = curve.GetKey(i)  
          if key.GetNBit(int(timeln)) == True:  
              tme = key.GetTime()  
              key.SetTime(curve,c4d.BaseTime(offset/fps+tme.Get()))  
      track = track.GetNext()  
  c4d.EventAdd(c4d.MSG_UPDATE)  
  
  return True  
  
def GetLastSelectedKey(track, timeln = 1) :  
  import c4d  
  
  if timeln == 1: timeln = c4d.NBIT_TL1_SELECT  
  elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT  
  elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT  
  elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT  
  else:  
      import math  
      timeln = math.fmod(timeln,4)  
      MoveSelectedKeys(op,offset,timeln)  
  
  curve = track.GetCurve()  
  cnt = curve.GetKeyCount()  
  
  for i in xrange(cnt) :  
      key = curve.GetKey(cnt-i-1)  
      if key.GetNBit(int(timeln)) == True:  
          return key  
  
def GetHNext(op) :  
  if not op: return  
  if op.GetDown() : return op.GetDown()  
  while not op.GetNext() and op.GetUp() :  
      op = op.GetUp()  
  return op.GetNext()  
  
def GetActiveObjects(doc) :  
  import c4d  
  lst = list()  
  op = doc.GetFirstObject()  
  while op:  
      if op.GetBit(c4d.BIT_ACTIVE) == True: lst.append(op)  
      op = GetHNext(op)  
  return lst  
  
  
def main() :  
  doc = documents.GetActiveDocument()  
  doc.StartUndo()  
  
  lst = GetActiveObjects(doc)  
  op = lst[0]  
  if not op: return False  
  
  key = GetLastSelectedKey(op.GetFirstCTrack())  
  if not key: offset = 0  
  else: offset = key.GetTime().GetFrame(doc.GetFps())-overlap  
  
  
  for i in xrange(len(lst)) :  
      doc.AddUndo(c4d.UNDOTYPE_CHANGE,op)  
      MoveSelectedKeys(op,offset)  
      key = GetLastSelectedKey(op.GetFirstCTrack())  
      if not key: offset = 0  
      else: offset = key.GetTime().GetFrame(doc.GetFps())-overlap  
      print op.GetName()  
      op = lst[i+1]  
  doc.EndUndo()  
  
  
  
if __name__=='__main__':  
  main()
</code></pre>
<p dir="auto">Here a tiny Screencast to show you how to use it:<br />
</p><div class="embed-container">
<iframe class="embed-video" src="https://www.youtube.com/embed/Ei_LjMVXklU" frameborder="0" allowfullscreen></iframe>
</div>" target="_blank" rel="noopener noreferrer nofollow ugc"&gt;<br />
<p></p>
<h1><div class="embed-container">
<iframe class="embed-video" src="https://www.youtube.com/embed/Ei_LjMVXklU" frameborder="0" allowfullscreen></iframe>
</div></h1>
]]></description><link>http://developers.maxon.net/forum/post/25689</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25689</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:35 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 26/02/2011 at 04:32, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">What means staggered ? Don't know the word ^^</p>
<p dir="auto">All explained here<br />
<a href="http://forums.cgsociety.org/showthread.php?f=182&amp;t=959094" target="_blank" rel="noopener noreferrer nofollow ugc">http://forums.cgsociety.org/showthread.php?f=182&amp;t=959094</a><br />
with sample file (first post)</p>
<p dir="auto">file shows example of before and after stagger</p>
<p dir="auto">hth</p>
]]></description><link>http://developers.maxon.net/forum/post/25688</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25688</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 26/02/2011 at 03:06, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">1:<br />
You can simply use the function in an iteration through the selected objects.</p>
<p dir="auto">What means staggered ? Don't know the word ^^</p>
<p dir="auto">2:<br />
Why modifieng the<br />
key value ? I thought it's about moving keys ?<br />
And what do you want to achieve with offset = offset + 10</p>
<p dir="auto">Don't select a track, select the keys.</p>
<p dir="auto">3:<br />
It's in the GetNBits() function. Search for it without the c4d. in front.</p>
<p dir="auto">I'll can answer your questions better later when im at home in about 2 hours.<br />
Till then,</p>
<p dir="auto">cheers</p>
]]></description><link>http://developers.maxon.net/forum/post/25687</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25687</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 26/02/2011 at 02:07, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi all</p>
<p dir="auto">Finally escaped from the last job.</p>
<p dir="auto">A couple of things</p>
<p dir="auto">1<br />
Confusion<br />
Just to confirm - the original concept was for staggered keys on multiple objects<br />
Don't get me wrong - not complaining - just need to be clear what I'm seeing</p>
<p dir="auto">The code is there in the while loop looks like it iterates through all the tracks of a single selected object.<br />
If I select more than one object - nothing happens? (no provision in script so far)</p>
<p dir="auto">2<br />
I'd assume (if you want to modify keys differently for different objects) it would be better to write a small function <br />
and modify the Key value before running Key.SetTime(...etc <br />
dependent on the number of selected tracks<br />
Sadly I cant see a way to return the count of selected tracks (yes Scott I now see the route) - so I guess <br />
the whole things needs to run in an outer loop - iterating through the selected objects?</p>
<p dir="auto">Another issue  - if you modify the offset inside the While track loop<br />
ie after<br />
key.SetTime..<br />
with something as simple as offset = offset + 10<br />
Assuming you have a POS ROT SCALE tracks as well<br />
Selecting all tracks is fine<br />
Selecting just one track ie POS - inserts two extra sets of keyframes<br />
as the while loop count is based on the total number of tracks<br />
Cant see a simple solution</p>
<p dir="auto">3<br />
can't find reference to<br />
C4d.NBIT_TL1_SELECT in the SDK - I take it these refer to the 4 timelines<br />
Where did you get that info pls?</p>
<pre><code>def MoveSelectedKeys(op,offset,timeln = 1) :    # offset in frames
    import c4d
  
    if (not op) or (not offset) : return False
  
    if timeln == 1: timeln = c4d.NBIT_TL1_SELECT
    elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT
    elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT
    elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT
    else:
        import math
        timeln = math.fmod(timeln,4)
        MoveSelectedKeys(op,offset,timeln)
  
    doc = op.GetDocument()
    doc.StartUndo()
  
    track = op.GetFirstCTrack()
    if not track: return False
  
    fps = float(doc.GetFps())
  
    while track:
        curve = track.GetCurve()
        cnt = curve.GetKeyCount()
        for i in xrange(cnt) :
            key = curve.GetKey(i)
            if key.GetNBit(int(timeln)) == True:
                tme = key.GetTime()
                doc.AddUndo(c4d.UNDOTYPE_CHANGE,op)
                key.SetTime(curve,c4d.BaseTime(offset/fps+tme.Get()))
        track = track.GetNext()
    doc.EndUndo()
    c4d.EventAdd(c4d.MSG_UPDATE)
  
    return True
  
  
import c4d
def main() :
    offset = 50 #change this value as needed
    MoveSelectedKeys(op,offset) 
  
if __name__=='__main__':
    main()
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/25686</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25686</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 25/02/2011 at 03:47, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Hi All</p>
<p dir="auto">Sorry for lack of contribution - yesterdays work over ran<br />
try to get back to this as soon as job is out of the door</p>
]]></description><link>http://developers.maxon.net/forum/post/25685</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25685</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 24/02/2011 at 08:34, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Let me add, that in the SkriptManager op is automatically the selected Object. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
And you don't need to overload the timeln since you don't want timeline 2,3 or 4.<br />
So this works too:</p>
<pre><code>  
    
    
    import c4d  
    def main() :  
      offset = 15 #change this value as needed  
      MoveSelectedKeys(op,offset)   
      
    if __name__=='__main__':  
      main()
</code></pre>
]]></description><link>http://developers.maxon.net/forum/post/25684</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25684</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 24/02/2011 at 08:34, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">OMG <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":slightly_smiling_face:" alt="🙂" /> - just dropped in for a look. Middle of some exhibition visual at present. Back this evening. Will have a good read later.</p>
<p dir="auto">cheers all</p>
]]></description><link>http://developers.maxon.net/forum/post/25683</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25683</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:34 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 24/02/2011 at 07:56, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Good job nux.<br />
I like how you implemented the other timeline windows.</p>
<p dir="auto">I needed to use a reverse loop in Coffee because if I had for example: keys ten frames apart and an offset value of ten. The first key would get moved on top of the last key. Then when the loop came around a second time. The keys were all on the same frame and it couldn't figure out what to move.<br />
I didn't know of any other way to do it.</p>
<p dir="auto">Deepshade,<br />
Just in case you don't know this. What nux posted is a method.<br />
So if you want to use this in the python script manager. You paste it above the def main section.<br />
Then call to the method like this:</p>
<pre><code>  
def main() :  
  obj = doc.GetActiveObject()  
  offset = 15 #change this value as needed  
  MoveSelectedKeys(obj,offset,timeln = 1)   
  
if __name__=='__main__':  
  main()
</code></pre>
<p dir="auto">-ScottA</p>
]]></description><link>http://developers.maxon.net/forum/post/25682</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25682</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:34 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:33 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 23/02/2011 at 21:55, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Now, i got it all work. Only thing missing is the GetNBit, cause I have not enough Time now. I'll post the full code later on. <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":slightly_smiling_face:" alt="🙂" /><br />
But a look in the SDK makes me think that CKeys doesn't have the function GetNBit because it's a method of the GeListNode Class.. ?</p>
<p dir="auto">PS: Still don't understand why you used an Invers Iteration.</p>
<p dir="auto">//edit:</p>
<p dir="auto">So, here's the complete function: <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":slightly_smiling_face:" alt="🙂" /><br />
Even with Undo-Functionality <img src="http://developers.maxon.net/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=0b8ddba251d" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";-)" alt="😉" /></p>
<pre><code>def MoveSelectedKeys(op,offset,timeln = 1) :    # offset in frames  
  import c4d  
  
  if (not op) or (not offset) : return False  
  
  if timeln == 1: timeln = c4d.NBIT_TL1_SELECT  
  elif timeln == 2: timeln = c4d.NBIT_TL2_SELECT  
  elif timeln == 3: timeln = c4d.NBIT_TL3_SELECT  
  elif timeln == 4: timeln = c4d.NBIT_TL4_SELECT  
  else:  
      import math  
      timeln = math.fmod(timeln,4)  
      MoveSelectedKeys(op,offset,timeln)  
  
  doc = op.GetDocument()  
  doc.StartUndo()  
  
  track = op.GetFirstCTrack()  
  if not track: return False  
  
  fps = float(doc.GetFps())  
  
  while track:  
      curve = track.GetCurve()  
      cnt = curve.GetKeyCount()  
      for i in xrange(cnt) :  
          key = curve.GetKey(i)  
          if key.GetNBit(int(timeln)) == True:  
              tme = key.GetTime()  
              doc.AddUndo(c4d.UNDOTYPE_CHANGE,op)  
              key.SetTime(curve,c4d.BaseTime(offset/fps+tme.Get()))  
      track = track.GetNext()  
  doc.EndUndo()  
  c4d.EventAdd(c4d.MSG_UPDATE)  
  
  return True
</code></pre>
<p dir="auto">Is there a bit for keys in the "usual" timeline ? This one does only affect the selected keys in the Manager .. <img src="smileys/smiley5.gif" alt="Confused" class=" img-fluid img-markdown" /></p>
<p dir="auto">Cheers, nux</p>
]]></description><link>http://developers.maxon.net/forum/post/25681</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25681</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:33 GMT</pubDate></item><item><title><![CDATA[Reply to Selected Keys? Move Keys? on Wed, 09 May 2018 17:51:33 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED</strong></em></p>
<p dir="auto"><em>On 23/02/2011 at 21:09, <strong>xxxxxxxx</strong> wrote:</em></p>
<p dir="auto">Uhm. just by the way: Why do we need a reversed loop ?</p>
]]></description><link>http://developers.maxon.net/forum/post/25680</link><guid isPermaLink="true">http://developers.maxon.net/forum/post/25680</guid><dc:creator><![CDATA[Helper]]></dc:creator><pubDate>Wed, 09 May 2018 17:51:33 GMT</pubDate></item></channel></rss>