Navigation

    • Register
    • Login
    • Search
    1. Home
    2. Vannipo
    V

    Vannipo

    @Vannipo

    0
    Reputation
    9
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    Vannipo Follow

    Best posts made by Vannipo

    This user does not have any upvoted posts yet.

    Latest posts made by Vannipo

    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    Hi @ferdinand @iplai ,

    Yes, sure, I already assigned hotkeys to my 9 scripts and made a folded palette and rendered 9 super sweet icons 🙂
    I was very disappointed as I found out, C4D does not support Numpad keys. So, the whole numpad keys are not useable. I mean, I can use them, but then I have to find new hotkeys for the commands I already use on the usual keys 1-9. Very sad 😞

    The most important point for an animator is to key the desired channel as fast as possible. I just got used to use the numpad keys 1-3 for position, 4-6 for rotation, 7-9 for scaling in other 3D tools. They perfectly ordered for those commands.

    But, the pop up idea is very interesting and I will have a look. Concerning the GUI... yes, I already saw something like this. I think the GUI builder is inside C4D, isn't it? I am not sure, atm.

    Btw, is it possible to set a "real name" for a script? atm, everywhere it just shows the filename.

    1de9c4f0-7e2d-4b15-9952-775b08a39bf7-image.png

    Cheers,
    Vannipo

    posted in Cinema 4D SDK •
    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    Hello @ferdinand,

    This is the final script for PositionX.
    I made it a bit shorter for making it more easy to adapt this to PosYZ/RotXYZ/SclXYZ.
    And I added a possibility to undo the complete action (e.g. if there was already a key, which got overridden and the user wants to revert this). I am not sure, whether the undo commands are in the right place, but after some research I placed the AddUndo before the stuff begins and it works so far. For all selected objects.

    Just wanted to post it, because maybe some else needs something like this.

    """Sets the current relative pos/rot/scl x/y/z-component of the selected object as a keyframe at the current
    time.
    """
    
    import c4d
    import typing
    
    doc: c4d.documents.BaseDocument # The active document.
    op: typing.Optional[c4d.BaseObject] # The active object, can be None.
    
    # The description level for the relative position, rotation, and scale parameter, we are going to
    # reuse these when defining IDs for each component of them.
    # Possible:  ID_BASEOBJECT_REL_POSITION // ID_BASEOBJECT_REL_ROTATION // ID_BASEOBJECT_REL_SCALE
    DLV_REL: c4d.DescLevel = c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION, c4d.DTYPE_VECTOR, 0)
    
    # The description levels for the x, y, and z components of a vector parameter.
    # Possible: VECTOR_X // VECTOR_Y // VECTOR_Z
    DLV_VEC: c4d.DescLevel = c4d.DescLevel(c4d.VECTOR_X, c4d.DTYPE_REAL, 0)
    
    # Define the IDs for the x/y/z relative SRT parameters.
    DID_SRT: c4d.DescID = c4d.DescID(DLV_REL, DLV_VEC)
    
    PRINT_MESSAGE = "Added Key PosX"
    
    def main() -> None:
    
        doc.StartUndo()
        for node in doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE):
            doc.AddUndo(c4d.UNDOTYPE_CHANGE, node)
            # Find the track for the parameter we are interested in creating, here the track for x
            # component of the relative position, or create a new track when there is none.
            track: c4d.CTrack = node.FindCTrack(DID_SRT)
            if track is None:
                track = c4d.CTrack(node, DID_SRT)
                if not track:
                    raise MemoryError(f"{track = }")
                node.InsertTrackSorted(track)
    
            # Get the current time and the key in #track for this time. CCurve.AddKey will return an
            # existing key if there is one, so we do not have to search for potentially existing keys
            # first.
            t: c4d.BaseTime = doc.GetTime()
            curve: c4d.CCurve = track.GetCurve()
            keyData: dict = curve.AddKey(t)
            if keyData is None:
                raise RuntimeError("Could not add key frame.")
    
            # Set the value of the key to the current value of that parameter.
            key: c4d.CKey = keyData["key"]
            key.SetValue(curve, node[DID_SRT])
    
            # Set different options for the key tangents
            key[c4d.ID_CKEY_PRESET] = c4d.ID_CKEY_PRESET_AUTO_OVERSHOOTWEIGHTED
    
        doc.EndUndo()
        # Push an update event to Cinema 4D.
        c4d.EventAdd()
    
        print (PRINT_MESSAGE)
    
    if __name__ == "__main__":
        main()
    

    Is there a documentation how to make a PlugIn of my 9 scripts?
    I mean, atm I just saved them into ..\Maxon Cinema 4D 2023_0AF8E603\library\scripts

    ae923af7-aded-4291-8f17-f46186067625-image.png

    Maybe it's enough doing a nicely named subfolder there and to add the folder to search location. I don't know. I'll try it out. Never installed a plugin or had a look into a plugin structure yet.

    Thank you very much again for your help, Sir!

    Kind regards
    Vannipo

    posted in Cinema 4D SDK •
    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    Thank you for the example.

    Yes, I know. Sorry again.
    Maybe ask the developers why it's not possible to assign hotkeys for keying SRT/X/Y/Z separately in vanilla C4D. This is a basic feature.

    I could show you how u could make C4D the best animation tool on earth in a 3 hours meeting. 🙂

    posted in Cinema 4D SDK •
    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    If I want to do something on the selected objects only (not the children), I use

    for op in doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE):
    # Do something with the selected objects #op
    ...

    Do I have to place it on top, before the definitions are done? Do I have to include everything or just where the key stuff starts?

    posted in Cinema 4D SDK •
    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    Hello @ferdinand ,

    ah, ok. I understand. Yes, this looks a bit more handy setting those parameters this way.

    Sorry, I have one more question:
    How I can make this work for my current selection? No matter, how many objects I have selected...
    Is it easy? Or do I have to create a "for-loop" and save my selection in the script before as an array?

    Are there any references how to do that?

    posted in Cinema 4D SDK •
    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    @ferdinand
    After some research I added

    key.ChangeNBit(c4d.NBIT_CKEY_AUTO, c4d.NBITCONTROL_SET)
    key.ChangeNBit(c4d.NBIT_CKEY_REMOVEOVERSHOOT, c4d.NBITCONTROL_SET)
    key.ChangeNBit(c4d.NBIT_CKEY_CLAMP, c4d.NBITCONTROL_SET)
    key.ChangeNBit(c4d.NBIT_CKEY_WEIGHTEDTANGENT, c4d.NBITCONTROL_SET)
    key.ChangeNBit(c4d.NBIT_CKEY_AUTOWEIGHT, c4d.NBITCONTROL_SET)
    

    after

    key.SetValue(curve, op[DID_POS_X])

    for getting smooth interpolation and default nice tangents.
    Works very nice so far.
    Thank you again, Sir!

    posted in Cinema 4D SDK •
    RE: HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    Hello @ferdinand,

    1st of all: Thank u very much for your support!
    I thought, there is maybe something existing, what I have missed. I understand, that's not the place to ask for ready-to-use-scripts. Really sorry.

    I know the autokeying feature. But this is exactly not something I am looking for, cause it sets keys only on existing curves and on curves, where I don't want a key to get added.
    E.g. if an object has curves for X and Z and keys are not at the same frame and I move the object in X, it also gets a key on Z. And that's exactly what messes clean curves...

    I will try out the script you posted.

    Again, thank you very much!

    Kind regards
    Vannipo

    posted in Cinema 4D SDK •
    HowTo set keyframes for PosXYZ/RotXYZ/ScaleXYZ with a script

    Hello folks!

    I am a senior animator for the past 20 years now. I am coming from Softimage. The best Animation Tool ever 🙂

    I have to switch to C4D now because at the moment I am working for a company. They work with C4D.

    There is something I really need for my animation workflow:
    I want to set a key on

    • Position X/Y/Z (XYZ separately)
    • Rotation X/Y/Z (XYZ separately)
    • Scale X/Y/Z (XYZ separately)

    with hotkeys.

    Due to the fact, this possibility is not given via the command manager (who knows why...), I need a Python script, which I can save in the PlugIn folder and assign a hotkey to this.

    Sadly I am no coder and need some help. Already found some stuff, but it's not really helping me with this problem. There is an old post, but this doesn't work anymore.
    https://plugincafe.maxon.net/topic/11552/set-keyframes-through-a-python-tag

    Some more information:
    0a621171-98af-4430-a599-52434114f831-image.png
    The the script should just execute this simple single click I can do with the left mouse button.
    For a single transform parameter. I just want to add a keyframe. If there is no track, one will be created, if there is one, a key will be added with the current value on the current frame of the scene.

    It should work for all the selected objects in this moment. Not for the Children.

    It would be so nice, if someone could help me with this. Just for PositionX. I think, I am able to adapt this to the other parameters.

    Kind regards
    Vannipo

    posted in Cinema 4D SDK •