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

    Load file/doc and then callcommand

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

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

      On 04/06/2012 at 20:26, xxxxxxxx wrote:

      Hello helpful cafe-ers!

      Long time lurker, first time caller, and I'm really sorry if this is a dumb question or posted incorrectly; just let me know if I'm doing something wrong.

      Right, so, here's basically what I want to do:

      import c4d
      from c4d import documents

      def main() :
          c4d.CallCommand(100004766) ##Select All in Object Manager
          c4d.CallCommand(16768) ##Connect and Delete

      if __name__=='__main__':
          main()

      So simple!  Right?  And, indeed, when I execute it everything works how I expect.  All of the objects in the object manager (that I've made polygon objects) are selected, connected, and deleted.  Now, when I add this before the two callcommands:

      path = '[insert file path here]'
          c4d.documents.LoadFile(path)

      It'll load the file just fine, but won't run the commands.  Furthermore, by way of testing things I would make code like this, for example:

      c4d.StopAllThreads()
          path = 'C:\\Users\\Dr. Doom\\Desktop\\RBDTestTarget\\RBDST_25.c4d'
          target = c4d.documents.BaseDocument()
          c4d.documents.LoadFile(path)
          target = c4d.documents.GetFirstDocument()
          
          c4d.documents.SetActiveDocument(target)
          target.InsertObject(c4d.BaseObject(c4d.Ocube)

      And the cube would be inserted.  If I traded the insert cube line with the callcommand()'s, however, they wouldn't work : \

      What am I not understanding about loading files and callcommands that's got me hung up?  I've also tried using LoadDocument with the objects flag, and a few other things, but no joy.

      Thanks so much for your help!
      Sorry for the post length.

      🙂

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

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

        On 14/06/2012 at 14:19, xxxxxxxx wrote:

        Ok, nevermind, calling the select all in object manager command wasn't working after the script loaded the file, so I just added a walk cycle that made everything active.

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