Navigation

    • Register
    • Login
    • Search
    1. Home
    2. mrittman
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by mrittman

    RE: Add/Remove Groups of User Data

    @m_magalhaes said in Add/Remove Groups of User Data:

    Hello,

    I was also talking about something like this. But it's not the best way to go. I suggest a TagData (plugin) with his own UI.

    pyTagCode = '\
    import c4d \n\
    #Welcome to the world of Python \n\
    \n\
    def main():\n\
        print "this ia a message"\n\
    \n\
    '
    
    
    
    import c4d
    
    # Main function
    def main():
        if op is None:
            gui.MessageDialog("Please selecte a target object")
        tag = c4d.BaseTag(c4d.Tpython)
        tag[c4d.TPYTHON_CODE] = pyTagCode
        op.InsertTag(tag)
        c4d.EventAdd()   
    
    # Execute main()
    if __name__=='__main__':
        main()
    

    By the way, don't forget you can save tag presets, that include python tags. You can simple add them with right click on your object in OM and "Load tag preset"

    Cheers,
    Manuel

    Oh this is good to know! Thanks so much for the information, this is quite helpful!

    Matt

    posted in Cinema 4D SDK •
    RE: Add/Remove Groups of User Data

    @zipit Thanks so much man, this is really quite helpful! I sure appreciate all the help!

    posted in Cinema 4D SDK •
    RE: Add/Remove Groups of User Data

    @m_magalhaes I see, but how do you create a script that generates a python tag with that code already in it?

    posted in Cinema 4D SDK •
    RE: Add/Remove Groups of User Data

    @m_magalhaes Hey man I'm so sorry I didn't see your reply! This was extremely helpful! Pretty much exactly what I was looking for.

    Do you know if this can be converted to a Python script so that I can drop it into any project?

    posted in Cinema 4D SDK •
    RE: Output Current Sound Track Name

    @s_bach Okay it's kind of working now, but is only outputting the last track in the list. I am using this script in a python tag:

    import c4d
    #Welcome to the world of Python
    
    def main():
    
        # find object in scene, store in obj
        obj = doc.SearchObject('VO')
    
    
        # store some variables
        track = obj.GetCTracks()
    
        obj[c4d.ID_USERDATA,4] = track[0].GetName()
        track[0][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,6]
        track[0][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,7]
        track[0][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,14]
    
        obj[c4d.ID_USERDATA,10] = track[1].GetName()
        track[1][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,11]
        track[1][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,12]
        track[1][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,9]
    
        obj[c4d.ID_USERDATA,15] = track[2].GetName()
        track[2][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,16]
        track[2][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,17]
        track[2][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,18]
    
        obj[c4d.ID_USERDATA,3] = track[3].GetName()
        track[3][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,20]
        track[3][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,21]
        track[3][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,22]
    
        obj[c4d.ID_USERDATA,24] = track[4].GetName()
        track[4][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,25]
        track[4][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,26]
        track[4][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,27]
    
        obj[c4d.ID_USERDATA,29] = track[5].GetName()
        track[5][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,30]
        track[5][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,31]
        track[5][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,32]
    
        obj[c4d.ID_USERDATA,34] = track[6].GetName()
        track[6][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,35]
        track[6][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,36]
        track[6][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,37]
    
        obj[c4d.ID_USERDATA,39] = track[7].GetName()
        track[7][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,40]
        track[7][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,41]
        track[7][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,42]
    
        obj[c4d.ID_USERDATA,44] = track[8].GetName()
        track[8][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,45]
        track[8][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,46]
        track[8][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,47]
    
        obj[c4d.ID_USERDATA,49] = track[9].GetName()
        track[9][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,50]
        track[9][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,51]
        track[9][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,52]
    
        obj[c4d.ID_USERDATA,54] = track[10].GetName()
        track[10][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,55]
        track[10][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,56]
        track[10][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,57]
    
        obj[c4d.ID_USERDATA,59] = track[11].GetName()
        track[11][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,60]
        track[11][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,61]
        track[11][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,62]
    
        obj[c4d.ID_USERDATA,64] = track[12].GetName()
        track[12][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,65]
        track[12][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,66]
        track[12][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,67]
    
        obj[c4d.ID_USERDATA,69] = track[13].GetName()
        track[13][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,70]
        track[13][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,71]
        track[13][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,72]
    
        obj[c4d.ID_USERDATA,74] = track[14].GetName()
        track[14][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,75]
        track[14][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,76]
        track[14][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,77]
    
        obj[c4d.ID_USERDATA,79] = track[15].GetName()
        track[15][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,80]
        track[15][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,81]
        track[15][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,82]
    
        obj[c4d.ID_USERDATA,84] = track[16].GetName()
        track[16][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,85]
        track[16][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,86]
        track[16][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,87]
    
        obj[c4d.ID_USERDATA,89] = track[17].GetName()
        track[17][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,90]
        track[17][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,91]
        track[17][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,92]
    
    
    
        # outputs the current track name where playhead is
        traks = obj.GetCTracks()
    
        for trak in traks:
    
            start = trak[c4d.CID_SOUND_START]
    
            # get length
            # length is stored as a string; need to convert it to int
            length = trak[c4d.CID_SOUND_LENGTH]
            length = length[:-2]
            length = int(float(length))
            fps = doc.GetFps()
            end = start + c4d.BaseTime(length, fps)
    
            # check if the current frame is within the range of the sound clip
    
            curTime = doc.GetTime()
    
            if curTime >= start and curTime < end:
                obj[c4d.ID_USERDATA,19] = trak.GetName()
            else:
                obj[c4d.ID_USERDATA,19] = "No Track"
    
            trak = trak.GetNext()
    
    posted in Cinema 4D SDK •
    RE: Output Current Sound Track Name

    Also, with this code, I am getting the spinning beachball of death 😕
    It must be trapped in the loop maybe?

    posted in Cinema 4D SDK •
    RE: Use a list or array for data?

    @m_magalhaes Yeah since the ID’s of my userdata are all over the place, maybe I better just stick with writing them all out 😕

    I was trying to make it so it started with just one track, and have an add/remove button at the top that would create additional tracks. But this starts to get extremely confusing for me to wrap my head around, as I’m only just a beginner.

    posted in General Talk •
    RE: Output Current Sound Track Name

    Thanks @s_bach, I really appreciate your help. I’m more of a motion designer, but wanted to tailor the scene I’m working on to make it easier.

    HTML/CSS come really easy to me, but my brain just comes to a halt when I try and get my head around python 😕

    posted in Cinema 4D SDK •
    RE: Add/Remove Groups of User Data

    @m_magalhaes I am writing it in a python tag.

    I should note that when it comes to programming, I’m not all that smart 😛

    posted in Cinema 4D SDK •
    RE: Output Current Sound Track Name

    @s_bach So something like this?

    track = op.GetFirstCTrack()
    
    while track is not None:
    
    start = track[c4d.CID_SOUND_START]
    
    # get length
    # length is stored as a string; need to convert it to int
    length = track[c4d.CID_SOUND_LENGTH]
    length = length[:-2]
    length = int(float(length))
    fps = doc.GetFps()
    end = start + c4d.BaseTime(length, fps)
    
    # check if the current frame is within the range of the sound clip
    
    curTime = doc.GetTime()
    
    if curTime >= start and curTime < end:
        print("Uses Track: " + track.GetName())
    else:
        print("no hit")
    

    I'm really struggling with wrapping my head around this 😞

    posted in Cinema 4D SDK •
    RE: Output Current Sound Track Name

    @s_bach I'm not super savvy when it comes to programming. If I had 18 or so tracks, what would be the proper way to write this code so it loops through all of them?

    posted in Cinema 4D SDK •
    Use a list or array for data?

    I've created a bunch of user data and want to insert it into several sound tracks. The issue is that it gets extremely tedious writing this. Is there a more efficient way to write all this using arrays or lists?

    I have attached an example oh how the user data looks within Cinema 4D.

        track = obj.GetCTracks()
    
        obj[c4d.ID_USERDATA,4] = track[0].GetName()
        track[0][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,6]
        track[0][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,7]
        track[0][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,14]
    
        obj[c4d.ID_USERDATA,10] = track[1].GetName()
        track[1][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,11]
        track[1][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,12]
        track[1][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,9]
    
        obj[c4d.ID_USERDATA,15] = track[2].GetName()
        track[2][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,16]
        track[2][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,17]
        track[2][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,18]
    
        obj[c4d.ID_USERDATA,3] = track[3].GetName()
        track[3][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,20]
        track[3][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,21]
        track[3][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,22]
    
        obj[c4d.ID_USERDATA,24] = track[4].GetName()
        track[4][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,25]
        track[4][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,26]
        track[4][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,27]
    
        obj[c4d.ID_USERDATA,29] = track[5].GetName()
        track[5][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,30]
        track[5][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,31]
        track[5][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,32]
    
        obj[c4d.ID_USERDATA,34] = track[6].GetName()
        track[6][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,35]
        track[6][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,36]
        track[6][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,37]
    
        obj[c4d.ID_USERDATA,39] = track[7].GetName()
        track[7][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,40]
        track[7][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,41]
        track[7][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,42]
    
        obj[c4d.ID_USERDATA,44] = track[8].GetName()
        track[8][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,45]
        track[8][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,46]
        track[8][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,47]
    
        obj[c4d.ID_USERDATA,49] = track[9].GetName()
        track[9][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,50]
        track[9][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,51]
        track[9][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,52]
    
        obj[c4d.ID_USERDATA,54] = track[10].GetName()
        track[10][c4d.CID_SOUND_ONOFF] = obj[c4d.ID_USERDATA,55]
        track[10][c4d.CID_SOUND_START] = obj[c4d.ID_USERDATA,56]
        track[10][c4d.CID_SOUND_NAME] = obj[c4d.ID_USERDATA,57]
    

    tracks.png

    posted in General Talk •
    Add/Remove Groups of User Data

    I've set up a user data interface, and would like to be able to click the add/remove buttons at the top, which would create additional tracks. Is this possible, or would one need to resort to C++ for this kind of behavior?
    user data.png

    For clarification, I am trying to do the Add/Remove behavior similar to how Constraint tags work:
    constraint.png

    posted in Cinema 4D SDK •
    RE: Output Current Sound Track Name

    Thanks so much @s_bach, this is really helpful!

    posted in Cinema 4D SDK •
    RE: access sound attributes using python API

    Thanks a ton @mafster, I really appreciate it! I think what I’ve got is pretty similar. I am using a python node inside of xpresso to target sound tracks.

    I notice you’re using CID_SOUND_NAME, while I’m using CID_SOUND_START. I hardly know anything about this stuff, so I hope I’m doing it correctly haha.

    import c4d
    #Welcome to the world of Python
    
    
    def main():
        global output_secs
    
        output_secs = input_secs # store input_secs inside output_secs
    
        sn = doc.SearchObject(input_name) # sound in timeline
    
        t = sn.GetFirstCTrack() # 1st track of object
    
        t[c4d.CID_SOUND_START] = c4d.BaseTime(output_secs)
    
    posted in Cinema 4D SDK •
    RE: access sound attributes using python API

    @mafster Any chance you could share the final script? I’m trying to do something similar and running into some roadblocks 😞

    posted in Cinema 4D SDK •
    Output Current Sound Track Name

    Anyone know if it's possible to output a track name when the playhead is hovering a particular soundwave in the timeline? I'm trying to display the name of the track in my viewport as I hear it play.

    Soundwave:
    sound track wave.png

    Track name example:
    track name.png

    Also, when I'm in a Take other than Main, it doesn't show the soundwave in the timeline. Is it possible to show this somehow?

    Sound tracks with Takes
    takes.png

    posted in Cinema 4D SDK •