Hi all,
I while ago I’ve started to tinker with Pyblish and how to incorporate it into Cinema 4D.
Think this would be very beneficial to our pipeline, which hopefully can translate to other teams.
Edit: Using Cinema 4D R19.053 for this.
As you probably know Cinema’s GUI environment does not allow to incorporate PyQt tools, so is my understanding that it only leaves a chance of running pyblish-qml to be used as an external GUI solution.
I will explain below about my setup to make it work and ask some questions along the way. Please correct me if I’m talking nonsense .
Cinema uses it’s own Python executable (v2.7.9) and the setup will be dedicated around its environment. This will remove any problems from reading modules outside Cinema.
I’m using Windows 7 command line but please feel free to point out any other CMD tools syntax.
With the directory selected install PyQt5 v5.7.1 from here:
C:\Program Files\MAXON\Cinema 4D R19\resource\modules\python\Python.win64.framework> python -m pip install git+git://github.com/pyqt/python-qt5.git
After installing PyQt, download pyblish-qml or pip
:
C:\Program Files\MAXON\Cinema 4D R19\resource\modules\python\Python.win64.framework> python -m pip install pyblish-qml
This will install Pyblish QML, but also the Pyblish Base module.
To run in inside Cinema need to create a script to call pyblish. This is my script attempt and where i can definitely will need help to understand:
# Import modules
import os
import pyblish.api as pyblish
import pyblish_qml
from pyblish_qml import api
import c4d
PATH_FILE, FILE_NAME_EXT = os.path.split(__file__)
# Register Cinema 4D Python Exec
api.register_python_executable(os.path.join(c4d.storage.GeGetStartupPath(), "resource", "modules", "python",
"Python.win64.framework", "Python.exe"))
# Register PyQt5 path
api.register_pyqt5(os.path.join(c4d.storage.GeGetStartupPath(), "resource", "modules", "python",
"Python.win64.framework", "Lib", "site-packages", "PyQt5"))
# Register Pyblish plugins path
pyblish.register_plugin_path(os.path.join(PATH_FILE, "plugins"))
def main():
"""
Main function.
"""
pyblish_qml.show() # Load Pyblish!
if __name__ == '__main__':
main()
As my understanding once Pyblish recognises your Python directory it will automatically find the PyQt module as well, which unfortunately didn’t work so needed to register both as above.
I’m also trying to add a custom plugins folder instead of the native path one, included with the Pyblish module.
So once you run the script inside Cinema you have the following log info.
Using Python @ 'C:\Program Files\MAXON\Cinema 4D R19\resource\modules\python\Python.win64.framework\Python.exe'
Using PyQt5 @ 'C:\Program Files\MAXON\Cinema 4D R19\resource\modules\python\Python.win64.framework\Lib\site-packages\PyQt5'
Targets: default
Starting pyblish-qml
Done, don't forget to call `show()`
Entering state: "hidden"
Entering state: "ready"
Entering state: "clean"
Entering state: "alive"
Settings:
HeartbeatInterval = 60
WindowTitle = Pyblish
WindowPosition = [100, 100]
WindowSize = [430, 600]
ContextLabel = Context
HiddenSections = [u'Collect']
Entering state: "visible"
Entering state: "initialising"
Entering state: "collecting"
Spent 288.00 ms resetting
Made 0 requests during publish.
Spent 518.00 ms resetting
Made 0 requests during reset.
Entering state: "ready"
No local comment, reading from context..
It works! For now…
So, next steps would be to start adding your own plugins and this is where it started to fail on me on my next post.