Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maya Installation Guide #4

Open
DJDhrub opened this issue Oct 28, 2017 · 17 comments
Open

Maya Installation Guide #4

DJDhrub opened this issue Oct 28, 2017 · 17 comments

Comments

@DJDhrub
Copy link

DJDhrub commented Oct 28, 2017

I am very interested in using cross3d. But It seems I am not that tech savvy like everyone. I brief note about how to get this to work with Maya will be helpful. One more thing to know does this work with Maya 2017?
Thanks.

@MHendricks
Copy link
Member

You can pip install cross3d, to install it in maya you may need to use the --target option so it's importable in maya. However, the current master branch requires using PyQt4, which is somewhat hard to get installed in most DCC's. I made a branch that uses Qt.py to handle the Qt requirements. I will probably use this to address the #3 pull request.

Manual Install
There should be a "Python\Lib\site-packages" folder in your Maya install. For example here is the default location on windows: "C:\Program Files\Autodesk\Maya2017\Python\Lib\site-packages" This is where you will copy the modules listed below. There could be other locations you can copy to, they just need to be importable in Maya's python.

Installing Qt.py
You will need Qt.py importable in Maya. Download Qt.py and save it with the filename "Qt.py" in your "Python\Lib\site-packages" folder. The version of Qt.py must be Qt.py 1.1.0.b3 or newer(the link is the latest code).

Installing cross3d
Download the zip file for the Qt_py branch of cross3d. Open the zip file and inside the cross3d-Qt_py folder there is a cross3d folder, Extract that folder to your "Python\Lib\site-packages" folder.

You should be able to import cross3d and start using it.

@DJDhrub
Copy link
Author

DJDhrub commented Oct 29, 2017

Hello!
I have done everything as you have asked. Then after starting Maya 2017 what .py file should I open to get the GUI?
When I am importing the init.py file in script editor from C:\Program Files\Autodesk\Maya2017\Python\Lib\site-packages\cross3d\maya
It shows me this

Error: line 1: ImportError: file line 11: No module named external

Tell me what am I doing wrong? How do I get the cross3d GUI?

@MHendricks
Copy link
Member

This api doesn't currently have any gui examples. It's a api to make writing a tool that works in multiple DCC's easier. https://github.com/blurstudio/cross3d#examples has a few examples of using the api, but we haven't had much time to add to them.

The api is setup so you should never need to import from the maya abstraction layer when making tools, you should only need to import and use the cross3d module(C:\Program Files\Autodesk\Maya2017\Python\Lib\site-packages\cross3d). The correct abstract, maya, motionbuilder, softimage, and studiomax module is automatically imported depending on which software you import cross3d inside of.

For example, if you want to create a camera and set its nearcliping plane

from cross3d import Scene
from cross3d.constants import ObjectType, CameraType
scene = Scene()
# Create a camera with the name of "testCamera". `CameraType.Physical` is not used in maya, but is used in studiomax(In Maya it will be ignored).
t = scene.createCamera('testCamera', type = CameraType.Physical)
# Set the near clipping plane and manually verify that it was correctly set.
t.setNearClippingPlane(1.0)
print t.nearClippingPlane()

@anooppc
Copy link

anooppc commented Jul 31, 2019

Hai can you help ,how to open cross 3d in maya2018, i did all, same as you tell, about manual install inside Maya

@anooppc
Copy link

anooppc commented Aug 6, 2019

Error: ImportError: file C:\Program Files\Autodesk\Maya2018\bin\cross3d\classes\dispatch.py line 10: DLL load failed: The specified module could not be found. #

@MHendricks
Copy link
Member

Are you using the Qt_py branch of cross3d? It should be using PySide2 for Maya 2018.

I should probably merge that branch as master is hard coded to import PyQt4 which is hard to install and PyQt5 is the only option for modern installs of Maya.

@anooppc
Copy link

anooppc commented Aug 7, 2019 via email

@melMass
Copy link

melMass commented Aug 7, 2019

@Annopc you cannot use both.
Maya ships with pyside2 but not PyQt by default.

@melMass
Copy link

melMass commented Aug 7, 2019

@MHendricks I have heard plans on updating this repo to blur's internal cross3d updates? Is this still planned ?
Thanks

@anooppc
Copy link

anooppc commented Aug 7, 2019 via email

@MHendricks
Copy link
Member

@MHendricks I have heard plans on updating this repo to blur's internal cross3d updates? Is this still planned ?

In the last few months we have started working on updating our code base and installs to pip installs. We are working on updating our code base so all internal development for cross3d will be in this repo. It's a slow process when combined with studio work so I don't know how soon it will happen.

Yes I cant use both, I'm using python 3.5 64bit

I haven't tried to run cross3d in python 3 yet so there could be issues with python 3 compatibility, but that doesn't explain DLL load failed error.

Which Qt.py binding are you using? This code will tell you what Qt binding Qt.py is using.

import Qt
print(Qt.__binding__)

If you have PyQt5 installed for maya Qt is going to default to PySide2 unless you tell it which to use using the QT_PREFERRED_BINDING environment variable. The QT_VERBOSE variable enables printing of lots of debug info on how Qt.py is initialized.

Are you able to import the modules directly?
from PyQt5.QtCore import Signal, QObject or from PySide2.QtCore import Signal, QObject

Where did you get a maya compatible PyQt5 build? We compiled our own internally.

@anooppc
Copy link

anooppc commented Aug 8, 2019 via email

@melMass
Copy link

melMass commented Aug 8, 2019

@anooppc You should format you answers it is quite hard to read...
To my knowledge you can't install pyqt5 this way (using pip install) because Maya depends on Qt and you can't mix Qt versions.
You instead have to build Qt in a specific way so it matches Maya's dependency version.

Fauvel's blogpost should point you in the right direction:
https://around-the-corner.typepad.com/adn/2019/01/how-to-build-pyqt5-for-autodesk-maya-2019.html

May I ask why you want to use PyQt5 specifically in maya ?

@anooppc
Copy link

anooppc commented Aug 8, 2019 via email

@anooppc
Copy link

anooppc commented Aug 9, 2019 via email

@MHendricks
Copy link
Member

You don't interact with the maya module directly(cross3d\maya\__init__.py). The software implementation modules are handled internally by the api.

Almost everything you use is accessed directly from the cross3d module.

import cross3d
# Create a scene object. Used 
scene = cross3d.Scene()
# iterate over the objects in the scene
for obj in scene.objects():
    print(obj)
# iterate over the selection
for obj in scene.selection():
    print(obj)
# create a new camera and query parameters
cam = scene.createCamera('test')
print(cam.fov())
print(cam.filmWidth())

Info about the application can be gotten from cross3d.application.

# inspect the application info
>>> print(cross3d.application.name())
Maya
>>> print(cross3d.application.year())
2019

There are a few more examples in the readme.

It looks like PySide2 doesn't allow you to override the connect method of a QObject, so the Dispatch and Application class will need modified to use a different method name. When using PyQt this makes it so any time a new scene is opened it will print New Scene in python.

def newScene():
    print('New Scene')
# connect the signal to the function
cross3d.dispatch.connect('sceneInvalidated', newScene)
# To disconnect the signals
cross3d.dispatch.disconnect('sceneInvalidated', newScene)

@anooppc
Copy link

anooppc commented Aug 13, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants