Load file/doc and then callcommand



  • 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.

    🙂



  • 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.


Log in to reply