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

    GetDocumentPath not getting full path?

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 399 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 30/05/2014 at 11:02, xxxxxxxx wrote:

      I have the following file:

      I:\PRJ\0_ADMIN\JESSE\SHOTS\JES_001\ADMIN\JES_001_ADMIN\JES_001_ADMIN_v12_PUB.c4d

      However, when I do the following :

      doc=c4d.documents.GetActiveDocument()
              fileDir=doc.GetDocumentPath()
              fileName=ntpath.basename( doc.GetDocumentName() )
              if fileDir and fileName :
                  filePath=os.path.join( fileDir, fileName )

      I get the following path:

      0_ADMIN\JESSE\SHOTS\JES_001\ADMIN\JES_001_ADMIN\JES_001_ADMIN_v12_PUB.c4d

      Which of course, doesn't exist.  Does anyone know why it is not returning the full path for my file?

      Also, it seems a bit...  Odd?  That when I use "GetDocumentName", it doesn't always return just the filename.  If I save the fullpath name, the document name is set to the full path, instead of just the file name.  Which is kind of non-intuitive.

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

        On 30/05/2014 at 14:45, xxxxxxxx wrote:

        I unfortunately can not reproduce your problem. Could you tell us what "fileDir" and "fileName"
        contain separately?

        -Niklas

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

          On 30/05/2014 at 15:14, xxxxxxxx wrote:

          Not sure I follow?  "fileDir" and "fileName" are set to the return value of the call to c4d.documents.

          I figured it out, I had to specifically use "SetDocumentPath" on the document I'm saving, for it to get the directory right when I call it later with "GetDocumentPath", which one would probably expect to be set automatically.  It would appear that, even if you use "SetDocumentName", and pass it the full file path, that it doesn't parse that for the directory path, and it doesn't parse it for just the filename either.  Instead, it appears that you have to set both the document name, and path, when saving, separately, which is one of the worst file save implementations I've come across so far.  😞

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

            On 08/07/2014 at 11:39, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            Not sure I follow?  "fileDir" and "fileName" are set to the return value of the call to c4d.documents.

            Sure, I see that in the code. But I was interested in the actual value of the variables which must
            differ from the result I see here on my machine, otherwise I could reproduce your problem. You
            didn't mention before that you are using SetDocumentName(), otherwise I could've told you what
            you just found out by yourself. 😉

            Originally posted by xxxxxxxx

            which is one of the worst file save implementations I've come across so far.  😞

            The method names indicate and the documentation explicitly states how these methods work. 
            It's just three lines btw.

            path, name = os.path.split(filename)
            doc.SetDocumentName(name)
            doc.SetDocumentPath(path)
            

            Best,
            -Niklas

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