ZOO TOOLS PRO: PYCHARM IDE SETUP

This page shows how to setup PyCharm so you can add tools to Zoo Tools Pro 2 with Python.

After you’ve completed this setup you’ll be able to add and navigate through our code, use auto-complete, go-to declarations and use PyCharm’s extra functionality.

PyCharm’s a great IDE (integrated development environment). If you’re using another IDE this page may still be helpful, you can follow the steps here and translate them to your program.

If you’ve only coded inside of Maya and have never used an IDE then you may find this setup cumbersome, but don’t worry, once you start working with PyCharm and Zoo you won’t want to return to the old ways of interacting with Maya.

 
 

GIT ACCESS


You can request direct GIT access to Zoo Tools Pro 2. Please email us if you are interested at info@create3dcharacters.com.

GIT access is not necessary for this tutorial.

 
 

WHAT YOU’LL LEARN

On this page, you’ll learn how to install Zoo tools Pro 2 and PyCharm.

You’ll learn how:

Zoo Tools Pro 2 is comprised of many Python Packages.
– you can configure PyCharm so it connects to Zoo Tools and Maya.
– to setup a PyCharm Project running Python 2.7
– external Zoo Packages connect to Zoo and PyCharm so you can add your code.

See our other tutorials for more details about coding with Zoo.

 
 

ROADMAP

We’re planning on making the creation and management of packages easier in the future. We have a planned UI called Package Manager that will be loaded within Maya for managing all Zoo Packages.

We’ll be refining the setup of Zoo Tools so it gets easier over time.

 
 

INSTALLING ZOO, PYCHARM, PYTHON & THE EXAMPLE PACKAGE

This section covers the installation of Zoo and PyCharm. You should also install a system version of Python for PyCharm.

Step 4 links to the zoo_example_custom_tools package download, this is where you’ll add your code and you can place it anywhere on your machine or network.

1. Install Zoo Tools Pro
Install Zoo Tools Pro 2 as per the Zoo2 Install Page . You can use the drag and drop or manual install methods.

2. Install Python 2.7.11
If you do not have Python 2.7.11 installed on your system it’s a good idea to download and install it here . More help is here . Maya comes with Python 2.7.11 bundled, but PyCharm prefers it to be installed on your system.

Note that Maya will upgrading to Python 3 in Maya version 2021. We will keep you posted on the upcoming change.

3. Install PyCharm Community Edition
Download and install the latest community edition of PyCharm here for your OS .

4. Download & Unzip The Package “zoo_example_custom_tools”
Download our example custom package zoo_example_custom_tools here . Unzip the folder and put it anywhere on a local drive or your network. The example folder will be our work area for the tutorials.

Since we’ll work out of a PyCharm Project directory later, you can place the package in a folder called “my_tools” or similar. The “my_tools” folder can contain many packages/repositories.

Example unzip location:
D:/yourPath/my_tools/zoo_example_custom_tools

Later you’ll be able to create and configure your own custom packages, but we’ll use the zoo_example_custom_tools package for now.

 
 

CONFIGURING ZOO IN PYCHARM

Now that you’ve installed everything, you need to start a PyCharm Project and add all the code to the project.

We’ll want the Zoo’s auto-complete and go-to declarations working within PyCharm.

Since Zoo is made of multiple Python Packages there’s a couple more steps to follow than the usual IDE configuration.

1. Create A New PyCharm Project
In PyCharm:

a) File > New Project
b) If unsure set the location of your “my_tools” directory.

Example PyCharm Project location:
D:/yourPath/my_tools/

This folder should contain the zoo_example_custom_tools folder we unzipped earlier.

c) Keep the “New Environment Using” radio button “on”
d) Set the Base Interpreter to Python 27
e) Click Create

You’ve now created a PyCharm Project. PyCharm marks the project with a hidden folder named “.idea” in the root of the “my_tools” directory.

The PyCharm Project automatically creates a new virtual environment with Python 2.7.

2. Add The Zoo Tools Pro 2 Code To PyCharm
Next, you’ll need to add the zootoolspro folder to PyCharm. The zootoolspro directory is where all the Zoo code is stored after installing it.

– Click File > Open… and add the zootoolspro folder (see below).
– In the popup window click Attach

This will add the zootoolspro code repository to the current PyCharm window.

Finding Your zootoolspro Folder
Your zootoolspro folder is usually found in your maya/scripts/ folder. In Windows it’s usually found at.

C:/Users/~YourUserName/Documents/maya/scripts/zootoolspro

If you’re unsure of your preferences location you can find it inside Maya by running the following Python code.

import os, sys, subprocess
import maya.mel as mel
directoryPath = os.path.abspath(os.path.join(mel.eval("internalVar -upd") , "../.."))
if sys.platform == "win32":
    os.startfile(directoryPath)
else:
    opener = "open" if sys.platform == "darwin" else "xdg-open"
    subprocess.call([opener, directoryPath])
print "Maya Preferences Directory Path: ", directoryPath

3. Add The Folder zoo_example_custom_tools
The PyCharm Project should already contain the package we downloaded earlier, but if it doesn’t add it to the project now. This folder will be our work area where we can extend Zoo and add code.

If the project does not already contain the zoo_example_custom_tools folder then:

– Click File > Open… and add the zoo_example_custom_tools folder.
– In the popup window click Attach

4. Set the startup “Source” Directory
Zoo is comprised of multiple Python Packages, and when it loads it combines all the packages into a single directory structure using pkgutil .

You’ll need to set all the packages as sources so PyCharm knows where to load our code.

Lets start with the Zoo startup package and mark it as a Source Root. This folder contains the startup code for Zoo.

In the Project tab open the zootoolspro folder to:

zootoolspro/install/core/python
– Select the python folder
Right-Click > Mark Directories As > Sources Root

The python folder should turn blue as it’s now a Source Root.

5. Set the Zoo Internal packages as “Source” Directories
Then you need to set all of Zoo’s internal packages sources. Go to:

zootoolspro/install/packages/

Inside this folder, you can see all of the internal Zoo Packages.

– Open each package and find its version number folder.
– Select all the version number folders.
Right-Click > Mark Directory As > Sources Root

You’ve now told PyCharm the location of all the internal Zoo code.

6. Set the zoo_example_custom_tools “Source” Directory
Now we’ll add the example-work-area package as a source. This is the folder named zoo_example_custom_tools that we unzipped earlier.

– Select the folder zoo_example_custom_tools
Right-Click > Mark Directory As > Sources Root

You’ve now told PyCharm where to find the zoo_example_custom_tools code.

7. Set Dependencies
Although you’ve set all the source directories, PyCharm still needs to be told that these packages are dependant on each other.

– Go to File > Settings > Project:my_tools > Project Dependencies
– Select each of the three repository folders and make sure all the sub-folders are checked on.

PyCharm now sees all the Source Packages as one and you can browse between all of the Zoo and example files with auto-completion.

8. Check The Code Is Working In PyCharm
You should test that the code has been setup correctly inside PyCharm.

– Go to the folder zoo_example_custom_tools/zoo/apps/uitoolsets/
– Open polycubebuilder_01_simple.py

Poly Cube Builder is a simple UI that builds a cube.

Check that the zoo imports are not underlined with red, on lines 14 – 16.

Ctrl-click on the word toolsetwidgetmaya on line 14, that should open the file toolsetwidgetmaya.py which is stored in the zoo_maya package.

The Zoo code has now been setup inside a PyCharm Project.

 
 

LOAD THE EXAMPLE TOOLS IN MAYA

Inside Maya we want to be able to use the new tools from the zoo_example_custom_tools package.

Editing package_version.config
A file called package_version.config tells Zoo which packages to run when Maya is loaded.

We need to add the new path of the zoo_example_custom_tools folder to the package_version.config file. Find it here:

zootoolspro/config/env/package_version.config

Double-Click this file in PyCharm to open it. It’s format is JSON.

Add the Example Tools package by adding the following lines of code to the JSON data.

},
    "zoo_example_custom_tools": {
        "type": "path",
        "path": "D:/yourPath/my_tools/zoo_example_custom_tools"
}

Be sure the path to your zoo_example_custom_tools folder is correct, and always use “/” forward slashes in JSON and Python path names.

Restart Maya To See The New Example Tools
Now restart Maya, when Zoo Tools Pro loads it will build a new shelf called “Custom_Tools”.

From inside Maya click on the first icon in the “Custom_Tools” shelf. You’ll see a drop-down list of tools. These tools are all the Toolset UIs in the folder:

zoo_example_custom_tools/zoo/apps/uitoolsets/

Setup Complete
You have successfully installed the Example Package in Pycharm, auto-complete and go-to declarations should now all be working. You can modify and add code as you wish.

 
 

MAKING ZOO CHANGES IN PYCHARM

From inside PyCharm open the Poly Cube Builder 01 UI

zoo_example_custom_tools/zoo/apps/uitoolsets/polycubebuilder_01_simple.py

You can find the icon of this tool on line 23:

"icon": "cubeWire",

Change this code to the save icon.

"icon": "save",

Now reload Zoo Tools to see the changes.

In Maya go:

ZooToolsPro (shelf) > Developer Icon (purple code icon) > Reload

Reload will rebuild the Zoo shelves and menus and reloaded all the code.

– Click on the Custom_Tools (shelf) > Green Sphere (icon) > Poly Cube Builder (Demo 01) Simple

You’ll see that the icon of the tool has changed to the internal “save” icon. You can see the changes in the menu too.

ZooTools (menu) > Modeling > Poly Cube Builder (Demo 01) Simple

Zoo Tools Pro 2 and PyCharm are working correctly. You can make code changes, reload Zoo in Maya and see your changes.

 
 

UPDATING ZOO TOOLS PRO 2

Please note that when you update Zoo Tools Pro 2 you will have to re-setup the zootoolspro folder and mark Source Root folders again.

See “Configuring Zoo In Pycharm” steps 2, 4, 5 and 7.

 
 

CUSTOMIZING PYCHARM

You can further customize PyCharm. The following steps are optional.

1. Set *.config files to be JSON
You can change the type of CONFIG files to format as JSON

File > Settings > Editor > File Types
– Highlight JSON in the side panel
– Add *.config and assign

2. Auto documentation as per Zoo
We use documentation that’s compatible with Sphinx Documentation .

To match the documentation type:

File > Settings > Tools > Python Integrated tools > Docstrings > reStructuredText

To automatically fill documentation when you type “”” under a function/method.

File > Settings > Editor > General > Smart Keys >
Python > Insert type placeholders in the documentation comment stub

You can also hit alt enter on the args and kwargs to add new variables to the docstring.

3. Add Code Glance plugin (sublime sidebar)
To add a visual scroll bar similar to the Sublime Text Editor you can add the third-party plugin Code Glance:

Settings > Plugin >
– Search for Code Glance, Install it and restart PyCharm

You will see a large scroll bar on the side of your code, this can be helpful while scrolling through your code.

4. Mouse Ctrl + Middle Wheel Sizes Text
In the Settings/Preferences dialog Ctrl+Alt+S, go to

File > Settings > Editor > General >
Mouse Control > Change font size with Ctrl+Mouse Wheel (on)

You can now ctrl-middle-scroll for text size.

 
 

SUMMARY

This completes the installation of Zoo tools Pro 2 within PyCharm.

You’ve learned how:

Zoo Tools Pro 2 is comprised of many Python Packages.
– you can configure PyCharm so it connects to Zoo Tools and Maya.
– to setup a PyCharm Project running Python 2.7
– external Zoo Packages connect to Zoo and PyCharm so you can add your code.

See our other tutorials for more details about coding with Zoo. It’s worth starting with the Zoo Code Overview Page .

Copyright Create 3d Characters 2021