Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    KeyframeSelection on Materials?

    Scheduled Pinned Locked Moved PYTHON Development
    13 Posts 0 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 24/01/2012 at 14:03, xxxxxxxx wrote:

      You guys did good on my previous keyframe selection question. So lets see how good you really are.😉
      Is it possible to use keyframe selections inside of materials?

      There's no DA_COLOR in the sdk so I tried DTYPE_COLOR.
      In C++ we have to use DTYPE_COLOR for the type when accessing color values. Not VECTOR. I'm not sure if that holds true with python or not:

      import c4d  
        
      def main() :  
        mat = doc.GetFirstMaterial()  
        
        color = c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR, what goes here?)  
        id = c4d.DescID(color, c4d.DescLevel(c4d.VECTOR_X, c4d.DA_REAL, c4d.DA_VECTOR)) #Red channel  
        mat.SetKeyframeSelection(id, True)  
        
      if __name__=='__main__':  
        main()
      

      Even If manually create a keyframe selection by right clicking on the red color channel and selecting it from the list of pop up options. It doesn't record with the record button.
      Is it possible that it's not something supported... even in the C++ API?

      -ScottA

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 25/01/2012 at 02:10, xxxxxxxx wrote:

        Hi,

        Here's how to keyframe select the color of a material:

        import c4d
          
        def main() :
            mat = doc.GetFirstMaterial()
            
            color = c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR)
            id = c4d.DescID(color)
            mat.SetKeyframeSelection(id, True)
            
            c4d.EventAdd()
          
        if __name__=='__main__':
            main()
        

        And I've been able to manually keyframe a material from green to red but we have to add the keyframe on the color. It seems not possible to animate R, g and B channels separately.

        EDIT:
        I had not seen we can show the color sub-channels...
        So here's the code to keyframe select R color chanel:

        import c4d
          
        def main() :
            mat = doc.GetFirstMaterial()
            
            color = c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR)
            id = c4d.DescID(color, c4d.DescLevel(c4d.VECTOR_X, c4d.DTYPE_REAL))
            mat.SetKeyframeSelection(id, True)
            
            c4d.EventAdd()
          
        if __name__=='__main__':
            main()
        

        And don't forget to call c4d.EventAdd(). I was searching why it wasn't working for some time when I remembered we had to call EventAdd() looking at the bend size keyframe script 🙂.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 25/01/2012 at 06:14, xxxxxxxx wrote:

          Here is a script that keyframes an animation to a material color from black to white:

          import c4d
            
            
          def main() :
              mat = doc.GetFirstMaterial()
              
              color = c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR)
              
              fps = doc.GetFps()
              minFrame = doc.GetMinTime().GetFrame(fps) # Get min time
              maxFrame = doc.GetMaxTime().GetFrame(fps) # Get max time
              
              channels = (c4d.VECTOR_X, c4d.VECTOR_Y, c4d.VECTOR_Z)
              for chan in channels:
                  id = c4d.DescID(color, c4d.DescLevel(chan, c4d.DTYPE_REAL))
                  track = c4d.CTrack(mat, id)
                  mat.InsertTrackSorted(track)
                  curve = track.GetCurve()
                  
                  # Add key at min frame
                  key = c4d.CKey()
                  key.SetTime(curve, c4d.BaseTime(minFrame, fps)) # Set key at min frame
                  key.SetValue(curve, 0.0)                        # Set channel to black
                  curve.InsertKey(key)
                  
                  # Add key at max frame
                  key = c4d.CKey()
                  key.SetTime(curve, c4d.BaseTime(maxFrame, fps)) # Set key at max frame
                  key.SetValue(curve, 1.0)                        # Set channel to white
                  curve.InsertKey(key)
              
              c4d.EventAdd()
            
            
          if __name__=='__main__':
              main()
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 25/01/2012 at 08:04, xxxxxxxx wrote:

            I already knew how to create tracks, curves, and keys for the three color sub-channels.
            But that code is a bit long in the tooth compared to using a keyframe selection to record color changes by the user.

            I can't can't get either one of your keyframe selection scripts to work for me in R12 or R13.
            The first one turns the "color" text red. Like it's active and ready. But when I press the record button nothing happens. The dot next to "color" does not turn red, and it does not set a key.

            Am I using this wrong?
            It's my understanding that keyframe selections are hooked to the record button. Like a list of specific things to record. Since the record button is greyed out when only a material is in the scene. I've been adding a cube and putting the material on that so the record button is available.

            If those KS scripts are working for you. I must be using them wrong.

            -ScottA

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 25/01/2012 at 08:56, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              Here is a script that keyframes an animation to a material color from black to white:

              If its any help Scott

              just checked this one on Studio R13

              create material
              run script

              Yup works

              MAterial animated from black to white
              Little red dots next to material colour

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 25/01/2012 at 09:13, xxxxxxxx wrote:

                This is the script I'm trying to use that doesn't work for me:

                import c4d  
                  
                def main() :  
                  mat = doc.GetFirstMaterial()  
                    
                  color = c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR)  
                  id = c4d.DescID(color)  
                  mat.SetKeyframeSelection(id, True)  
                   
                  c4d.EventAdd()  
                  
                if __name__=='__main__':  
                  main()
                

                I'm simply trying to enable the keyframe selection option on it so I can set keys with c4d.CallCommand(12410). Rather than having to create tracks, curves, and keys the long way.

                -ScottA

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 25/01/2012 at 09:30, xxxxxxxx wrote:

                  I tried a similar thing earlier but didn't get more than the yellow highlighted word 'colour'

                  then the day job took over

                  sorry can't be more help

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 25/01/2012 at 13:22, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    I already knew how to create tracks, curves, and keys for the three color sub-channels.
                    But that code is a bit long in the tooth compared to using a keyframe selection to record color changes by the user.

                    I can't can't get either one of your keyframe selection scripts to work for me in R12 or R13.
                    The first one turns the "color" text red. Like it's active and ready. But when I press the record button nothing happens. The dot next to "color" does not turn red, and it does not set a key.

                    Am I using this wrong?
                    It's my understanding that keyframe selections are hooked to the record button. Like a list of specific things to record. Since the record button is greyed out when only a material is in the scene. I've been adding a cube and putting the material on that so the record button is available.

                    If those KS scripts are working for you. I must be using them wrong.

                    -ScottA

                    My guess is using the command to drive the button 
                    needs a parameter to create the track
                    this was happening with the bend deformer

                    the colour  doesn't have a way to create the track - so running the record button command doesn't do anything?

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 25/01/2012 at 14:25, xxxxxxxx wrote:

                      Look at Yannick's first reply.
                      There are two script examples that enable the keyframe selection option for the color attribute. One for the parent channel. And one for the individual subchannel.
                      But what purpose does doing this serve. If the record button doesn't set new keys?
                      He made it sound like they worked for him. But I don't see how.

                      As I said earlier.
                      AFAIK. The entire purpose for the existence of the keyframe selection option is to give the user the ability to key these attributes using the record button. Instead of diving down into the tracks&Curves level....Even on things that don't already have any tracks on them yet.
                      That's how it works on other things.

                      The reply I had expected to get was:
                      A. This is a bug
                      or
                      B. This is a known limitation. And the programmers forgot to grey out the Animation->Add Keyframe Selection option in the right click menu in the materials pallet.

                      -ScottA

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 25/01/2012 at 23:30, xxxxxxxx wrote:

                        Totally agree about the shortcut to record
                        I'd also like to know

                        Over to Maxon for a reply then.......

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 26/01/2012 at 05:44, xxxxxxxx wrote:

                          The purpose of Keyframe Selections is to record the set parameters in Auto-Key mode if the set parameters change.

                          From the docs:

                          **Add Keyframe Selection

                          To create a keyframe selection, select several parameters and choose Add Keyframe Selection. The selected parameter names will be colored to indicate that they belong to the keyframe selection. When you use CINEMA 4D's autokeying mode, only parameters in the keyframe selection will be recorded (provided their values actually change).**

                          The record button only records changes of selected objects not materials, tags etc.

                          cheers,
                          Matthias

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 26/01/2012 at 07:55, xxxxxxxx wrote:

                            Apologies for newb question below.......

                            So there is no way to actually record keyframes (as in red dots)
                            other than the long way, create tracks etc 
                            UNLESS you have an Object in the OM....OK

                            Q: could the app be tricked into recording - material changes, tags etc, by breifly setting autokey on...doing something...then turning off.... somehow?

                            Just looking for an easy life when it comes to creating keyframes 🙂

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 26/01/2012 at 08:13, xxxxxxxx wrote:

                              Hi Matthias,
                              Sorry to pull you away from your work.

                              I could not find this in any of the docs:
                              "The record button only records changes of selected objects not materials, tags etc."
                              I had sort of guessed that was the case. But I've often guessed wrong about things in the past.

                              There's no indication that Animation->Add Keyframe Selection will, or will not, work in any given situation. The option is there for everything including materials and tags.
                              To make things even more confusing to the user. That option WILL turn the attribute red..fooling the user into thinking it's available... When it isn't.
                              Making the user(or at least me) feel like it's an option. But they aren't using it correctly.

                              It would be great to see tags and materials working with this option in the future. It requires less coding to key them that way.
                              But if not. Could you guys please add a warning about this to the docs?

                              Thanks for the help,
                              -ScottA

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post