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
    • Recent
    • Tags
    • Users
    • Login

    CommandLine.exe and Python scripts...

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 595 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

      On 19/02/2015 at 08:56, xxxxxxxx wrote:

      Hello All,

      I have been working on a python script in C4D which has been progressing nicely. The script is part of the document, which automatically gets executed when there is a screen update, etc. I use this script to modify colors of mats, set timeline propterties, etc, based on a file input.

      This works fine when I execute it within the GUI, however, when I want to render a movie or image of that same project via the commandline:

      "...\CINEMA 4D R16\Commandline.exe" -render "...\TestComp_3Dmap.c4d" -frame 0 0

      I see in the commandline an error with the script:

      Traceback (most recent call last) :

      ...(some error)...

      Printing useful details like the document works fine:

      doc = 4d.documents.GetFirstDocument()
      print doc

      <c4d.documents.BaseDocument object called '' with ID 110059 at 0x0000007F9C4FC170>

      however, when I try to print the doc's objects:

      objs = doc.GetObjects()
      print objs

      []

      it returns with an empty list, where in the GUI it returns all the objects in the doc.

      My question is, what am I doing wrong here, why does it behave differently in CommandLine vs the GUI? Perhaps I can place/start the script elsewhere to make it work?

      Looking forward to possible answers,

      David

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

        On 19/02/2015 at 11:15, xxxxxxxx wrote:

        Since there's no gui with command line, the active document concept gets a little strained.

        It sounds like you're putting stuff in a Python tag? I find I have the most success by defining doc via op.GetDocument() rather than GetActiveDocument().

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

          On 25/02/2015 at 03:18, xxxxxxxx wrote:

          Hi Rick, the op.GetDocument() works as expected, thanks!

          I'm facing a new problem with scrubbing/updating.

          Changing an objects material, eg:

          tag = obj.MakeTag(c4d.Ttexture)
              tag.SetMaterial(existingMat)

          works fine, I can see different results from commandline.

          However, changing an objects animation curve doesn't update it, eg:

          zcurve = obj.GetCTracks()[2].GetCurve() # GetCTracks() = [x, y, z]
              key = zcurve.GetKey(1)
              key.SetValue(zcurve, height)

          The value of the key gets changed, but aren't reflected in the output.

          c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED), c4d.EventAdd(), obj.Message(c4d.MSG_UPDATE), zcurve.SetKeyDirty() do not help.

          I must be missing that one update message that I cant seem to find.

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

            On 25/02/2015 at 05:32, xxxxxxxx wrote:

            After some further testing, it seems that the change of the track only gets reflected on the second frame rendered.

            So the first frame has no changes, but the second frame DOES have the correct changes.

            Weird that the material change is seen on the first frame output right away, but not the curve changes.

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

              On 25/02/2015 at 06:54, xxxxxxxx wrote:

              Hello,

              for new questions no longer related to this thread's topic please open a new threads. Thanks.

              Please also share some more information on what kind of plugin you write.

              Best wishes,
              Sebastian

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