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
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login
    1. Home
    2. mafster
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 12
    • Best 1
    • Controversial 0
    • Groups 0

    mafster

    @mafster

    1
    Reputation
    53
    Profile views
    12
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    mafster Unfollow Follow

    Best posts made by mafster

    • RE: access sound attributes using python API

      Hey @mrittman, i cant find the id names in documentation but i think CID_SOUND_START would be the timecode of when the audio starts (notice you are assigning a BaseTime object to it) CID_SOUND_NAME which i'm using is the audio file path.

      My application is taking the audio file path and the image sequence output (as defined by the render output settings) and combining them via a subprocess using ffmpeg. If there was a way i could do it straight through c4d id prefer that! Mainly cos ffmpeg is a mission! especially when you need to shift/delay audio and what not.

      posted in Cinema 4D SDK
      M
      mafster

    Latest posts made by mafster

    • controlled rendering programmatically

      Hi there,

      I'm wanting to render frames but would like to control the step dynamically. Sometimes rendering groups of frames than a gap then groups etc.
      I can manage the logic of frame steps/groups but wondering if there is a command exposed to python to render a frame(s)?

      Also would this be better suited as a bash command process to run instead? Either way works for me but at the moment i cant find info on rendering programatically in c4d using any of these approaches.

      Cheers

      posted in Cinema 4D SDK sdk python
      M
      mafster
    • How to identify and access a CTrack using it's ID "CTsound"

      Hi there,

      I'm wondering if there is a way to get the CTrack on an object specified by its type, specifically an audio track?

      Currently i just grab the first CTrack which doesnt help if there is a keyframe or some other track also on the object.

      from c4d import document
      doc = documents.GetActiveDocument()
      
      obj = doc.SearchObject('sound')   # A convention used in studio to get the object by name
      
      sound_track = obj.GetFirstCTrack() 
      
      sound_track[c4d.CID_SOUND_START]  # This will return NoneType if sound_track is actually something else, therefore doesnt carry this property.
      

      Anyone have any idea how to do this without using GetFirstCTrack()? Im guessing it will somehow need to use the ID for special CTrack "CTsound" but im not really sure how to use it.

      Thanks in advance!

      posted in Cinema 4D SDK python r20
      M
      mafster
    • RE: Unable to kill my C4DThread

      @r_gigante By default thread.Wait() should pass in True?

      I just had a thought because the thread.Wait() in my case is a property of self

      self.thread.Wait()
      

      is it possible self is being passed in (as Python does) and its reading that as a the bool argument and so getting type Error?

      posted in Cinema 4D SDK
      M
      mafster
    • RE: Unable to kill my C4DThread

      @r_gigante

      Thanks for the example. In my case this just causes C4d to freeze wile the process is running. Once its done then i get c4d back again.

      Strangely if i leave the bool argument out out from Wait() method it will error (Type error) but then the ffmpeg will still be running (as its running from the Start() method and c4d is responsive and also closes gracefully.

      This seems an entirely non-elegant and accidental way of finding a "solution" essentially using an error to give me the result i want. I accidentally left out the boolean argument, everything seemed to work and then checked the logs and realised the error.

      posted in Cinema 4D SDK
      M
      mafster
    • RE: Unable to kill my C4DThread

      @mp5gosu I should also mention that i tried calling self.End() from within the thread which i had heard isnt good practice. But anyway...didnt work XD

      posted in Cinema 4D SDK
      M
      mafster
    • RE: Unable to kill my C4DThread

      @mp5gosu thanks for the reply. I use Thread.Start().

      I also run the thread from within a gui.GeDialog. Command() method

      def Command()
          self.thread = myThread.MyThread()
          self.thread.data = data  # Load some data in
      
          self.thread.Start()
      
      

      I'm guessing i may need to call End() somewhere? However this dialog closes after the thread starts. I figured the thread would be garbage collected once its done with its process.

      posted in Cinema 4D SDK
      M
      mafster
    • Unable to kill my C4DThread

      As in the title, I've got a BaseThread running which i think doesnt die once process is finished.

      The thread runs an ffmpeg call via subprocess.wait() (also tried communicate()). Everything seems to work but after closing cinema4d i cant reopen it, in the task manager there is a c4d process still there taking minimal resources. If i kill that task i can then reopen c4d again. My guess is im not using the threads correctly and the thread stays round after the process is finished.

      My code below:
      note: self.data is added to the thread elsewhere. Suppose I could add in init as well.

      class CompileAVThread(c4d.threading.C4DThread):
      
          def Main(self):
      
              result = compile_av(**self.data)
      
              if result is True:
                  gui.MessageDialog('Export completed')
                  path = os.path.dirname(self.data['output'])
                  open_path(path)  # separate def that opens native os file browser at correct location
      
              else:
                  print('Something went wrong')
                  gui.MessageDialog('Failed')
      
              if self.TestBreak():
                  # Dont really get how TestBreak works..
                  print('Exiting thread please?')
                  return
      

      And the subprocess:

      p = subprocess.Popen(args=arg_list, shell=False)
      
      if p.wait() == 0:
          return True
      else:
          print "Failed - %s" % p.stdout.read()
          return False
      
      posted in Cinema 4D SDK
      M
      mafster
    • RE: access sound attributes using python API

      Hey @mrittman, i cant find the id names in documentation but i think CID_SOUND_START would be the timecode of when the audio starts (notice you are assigning a BaseTime object to it) CID_SOUND_NAME which i'm using is the audio file path.

      My application is taking the audio file path and the image sequence output (as defined by the render output settings) and combining them via a subprocess using ffmpeg. If there was a way i could do it straight through c4d id prefer that! Mainly cos ffmpeg is a mission! especially when you need to shift/delay audio and what not.

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

      @mrittman sure thing:

      from c4d import documents
      
      doc = documents.GetActiveDocument()
      
      obj = doc.SearchObject('sound')  # "sound" is just an in-house convention...could be anything
      
      # Note there its the first track. Also convention...
      sound_track = obj.GetFirstCTrack()
      
      # Get the audio file
      audio_path = sound_track[c4d.CID_SOUND_NAME]
      
      

      If i had to get the soundtrack another way by name or something i wouldnt quite know. Im guessing using sound special track id or something might do it...im very experienced with python but complete noob to c4d 😄 just a couple weeks back.

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

      So i figured it out. This is what i needed.

      sound_track[c4d.CID_SOUND_NAME]
      sound_track[c4d.CID_SOUND_START]
      

      I also found out an extremely useful little thing! You can drag and drop attributes into the console to get their id....that should be on the front page of the python documentation 😛 for people starting in c4d py dev!

      Not sure how to set this to SOLVED

      posted in Cinema 4D SDK
      M
      mafster