Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Help with BaseList2D.SetKeyframeSelection()

    PYTHON Development
    0
    7
    1.6k
    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
      Helper
      last edited by

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

      On 28/01/2011 at 17:49, xxxxxxxx wrote:

      I want to add keyframe selections to certain properties of an object, for the sake of argument the ID_BASEOBJECT_REL_POSITION property.

      The method wants a DescID type for the 1st argument and 0 or 1 for the second argument.
      Unfortunately I have no idea how to get the DescID for the ID_BASEOBJECT_REL_POSITION property.

      I can do it with an empty DESCID like this :

      id = c4d.DescID()
      obj.SetKeyframeSelection(id, 1)

      I know it works because subsequently hitting the set key button doesn't generate any keyframes but I don't know how to read a specific property into the DescID.

      Can anyone provide an example ?

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

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

        On 29/01/2011 at 06:16, xxxxxxxx wrote:

        Well I managed to get it to work with User Data, without really understanding why, by copying and altering a chunk of code I found:

        id = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0),c4d.DescLevel(1))
        obj.SetKeyframeSelection(id, 1)

        But I still can't work out how to do it for the default properties, such as ID_BASEOBJECT_REL_POSITION, I just don't know the syntax.

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

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

          On 29/01/2011 at 07:28, xxxxxxxx wrote:

          OK, seems I found the syntax which works for every parameter apart from the coordinates :

          id = c4d.DescID(c4d.ID_BASEOBJECT_VISIBILITY_EDITOR)
          obj.SetKeyframeSelection(id, 1)

          But it won't work for any of the coordinates, be they position, rotation, scale, rel or frozen.
          Is this a bug ? or something special I have to do for these parameters ?

          I thought this would work but no result :

          id = c4d.DescID(c4d.ID_BASEOBJECT_REL_POSITION)
          obj.SetKeyframeSelection(id, 1)

          For anyone who's interested, my code for setting keyframe selections on userdata container some un-needed stuff, this is sufficient :

          id = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(1))
          obj.SetKeyframeSelection(id, 1)

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

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

            On 30/01/2011 at 10:23, xxxxxxxx wrote:

            In case it isn't clear what I'm trying to do :

            My code should do the same as highlighting the object's parameter in the attribute manager, right clicking for menu and choosing Animation > Add Keyframe Selection. This makes the parameter turn orange and now when the 'set key' button is pressed with the object selected, only these highlighted parameters are keyframed.
            This is useful to avoid generating unnecessesary keyframes on tracks you don't want to key, for example no point generating scale keys on a character's foot controller. It's also useful to make sure that user data or particular parameters are keyed along with position, rotation etc.

            According to the python documents, you can do this in code by using the BaseList2D.SetKeyframeSelection() method.

            The first argument you supply is the DescID of the parameter whose KeyframeSelection state you want to change and the second argument you supply is if it is in the Keyframe selection or not, using 0 for 'is not' and 1 for 'is'.

            So the code :

            id = c4d.DescID(c4d.ID_BASEOBJECT_VISIBILITY_EDITOR)
            obj.SetKeyframeSelection(id, 1)

            sets the object's 'Visibile in editor' parameter as part of the KeyframeSelection
            but when I try to do the same for the object's position parameter :

            id = c4d.DescID(c4d.ID_BASEOBJECT_REL_POSITION)
            obj.SetKeyframeSelection(id, 1)

            it doesn't work, the writing doesn't turn orange and position is not keyed when the 'set key' button is pressed. The same happens with any parameter in the 'Coord.' tab.

            So either I need to use different syntax for these parameters, or there is a bug in this method.
            Hope that explains it better.

            Another user noted that it isn't working in C++ either, here's his code:

            BaseObject *myObject = doc->GetFirstObject();
            myObject->SetKeyframeSelection(ID_BASEOBJECT_VISIBILITY_EDIT OR,1); // This works fine
            myObject->SetKeyframeSelection(#ID_BASEOBJECT_REL_POSITION,1 ); // This DOES NOT work!!
            EventAdd();

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

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

              On 30/01/2011 at 18:27, xxxxxxxx wrote:

              Hi decade,

              please try the following lines:

              rel_pos=c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION, c4d.DA_VECTOR, c4d.Obase)
              id = c4d.DescID(rel_pos, c4d.DescLevel(c4d.VECTOR_X, c4d.DA_REAL, c4d.DA_VECTOR))
              op.SetKeyframeSelection(id, True)
              id = c4d.DescID(rel_pos, c4d.DescLevel(c4d.VECTOR_Y, c4d.DA_REAL, c4d.DA_VECTOR))
              op.SetKeyframeSelection(id, True)
              id = c4d.DescID(rel_pos, c4d.DescLevel(c4d.VECTOR_Z, c4d.DA_REAL, c4d.DA_VECTOR))
              op.SetKeyframeSelection(id, True)
              

              The selection must be assigned to each subchannel. The TranslateDescID function in C++ helps here to get the corresponding DescID, but this is currently not wrapped in Python. Anyway, the lines I posted should help you here.

              Cheers, Sebastian

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

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

                On 30/01/2011 at 19:16, xxxxxxxx wrote:

                I know this is the Python forum.
                But do you happen to know the C++ equivalent to this code Sebastian?

                I tried to convert it myself. But I'm still too new at the C++ API to get it converted correctly.

                -ScottA

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

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

                  On 31/01/2011 at 13:46, xxxxxxxx wrote:

                  Many thanks, Sebastian !

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