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

    PySide2 Integration

    General Talk
    python
    4
    8
    2.6k
    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.
    • A
      Aeoll
      last edited by a_block

      Hi,

      I'm coming to C4D scriptin from a Houdini background. I've made a project loader/saver dialog which is working in Houdini/Nuke (they both ship with PySide2) and would like to use the interface in C4D.

      On copying the PySide2 lib from the Houdini site-packages I'm hit with DLL errors. It also seems PySide2 is not available as a wheel or using pip with Python27?

      My workaround has been to install PySide into the C4D PYTHONPATH (which works fine) and use Qt.py for compatibility, but I'm wondering if anyone has successfully managed to use PySide2 with C4D?

      1 Reply Last reply Reply Quote 1
      • A
        Aeoll
        last edited by Aeoll

        Additional question:
        I'm creating a QApplication and then a QDialog but I can't seem to close the QApplication at all when the dialog is closed?
        This means even when C4D is closed normally it's still running in the background and needs to be force-quit. Any suggestions appreciated

        1 Reply Last reply Reply Quote 1
        • fwilleke80F
          fwilleke80
          last edited by

          Why don't you avoid all those difficulties and simply implement that dialog using the C4D UI?

          www.frankwilleke.de
          Only asking personal code questions here.

          1 Reply Last reply Reply Quote 1
          • a_blockA
            a_block
            last edited by

            Hi,

            here at MAXON we have no experience with PySide, I can't really give much feedback on that specifically.

            In general we try to stick to the environment described by the VFX Reference Platform. For Python this means, inside of Cinema 4D it is still Python 2.7 being used. As far as I can see, PySide2 relies on Python 3, only. So I doubt, it's possible to make use of PySide2 inside of Cinema 4D at the moment.

            Also we do not recommend to mix other/external GUI systems in Cinema 4D plugins. Another thing we can not really provide support for. I have the feeling in order to get constructive feedback on your last question about the application staying open upon quitting Cinema 4D you'd need to provide additional details. I would leave this topic to our community. My recommendation would be to go with @fwilleke80's suggestion and stick to Cinema 4D's GUI system.

            I have turned this thread into a question and moved this thread to the General Programming & Discussions category.

            Cheers,
            Andreas

            1 Reply Last reply Reply Quote 1
            • A
              Aeoll
              last edited by

              @fwilleke80 - I was just hoping to avoid rewriting existing code I have working in Houdini/Nuke, as it's 80% ui-building and cleanly shared between implementations. I've also never used the c4d python api and don't use C4D at all.

              @a_block Thanks for the help. Houdini/Nuke both use Python27 with PySide2 although I'm not sure of the details

              1 Reply Last reply Reply Quote 0
              • A
                Aeoll
                last edited by a_block

                I've solved my 2nd issue which is good news.
                I have a general c4d api question which I'll post here to avoid spam:

                I'm calling c4d.documents.SaveDocument() with a new filepath, expecting this to work like a 'save as' command with the open scene becoming this new file.

                However it doesn't I've had to do this workaround, which seems strange?

                scene = c4d.documents.GetActiveDocument()
                c4d.documents.SaveDocument(scene, newpath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT)
                c4d.documents.LoadFile(newpath)
                c4d.documents.KillDocument(scene)
                
                M 1 Reply Last reply Reply Quote 0
                • a_blockA
                  a_block
                  last edited by

                  Hi,

                  indeed SaveDocument() does save the document, only.
                  Your approach of simulating "save as" functionality is fine. If you can live with a requester, you could also use SAVEDOCUMENTFLAGS_SAVEAS instead.

                  If you don't mind, I'd like to ask you to please open separate threads for such unrelated questions. We do not regard this as spamming, but regard it helpful for future users searching for certain information. Such questions would go into the Cinema 4D Development category.
                  Also please consider using code tags. I have changed this in your previous post.

                  Cheers,
                  Andreas

                  1 Reply Last reply Reply Quote 0
                  • M
                    mikedatsik @Aeoll
                    last edited by

                    @Aeoll
                    Additional question:

                    I'm creating a QApplication and then a QDialog but I can't seem to close the QApplication at all when the dialog is |
                    closed?
                    This means even when C4D is closed normally it's still running in the background and needs to be force-quit. Any |
                    suggestions appreciated

                    I have the same issue with PySide. You mentioned that sole this issue. Could you Help me?

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