Maya: Pycharm autocomplete maya.cmds requirements and implementation

Hello All,

Hope you all are doing fine. I was searching and reading something about environment variables of maya and then i spotted using maya through external interpreter, I was like wait, forget about external interpreter, how to use maya cmds outside of maya script editor, this was an old bucket list task. So i decided to do this and realized, SHIT! this is a tedious task only because of maya docs – has no information at all.

But the maya community is just amazing, alot of people have uploaded amazing blog posts. You can read it in the helpful links section.

Requirements

Things to do

copy the devkit zip file in devkit folder – C:\Program Files\Autodesk\Maya2020\devkit

and export it exactly there, as you can see in the below image – devkitBase

Launch PycharmI am using 2023

Note: Purpose of the post is not to explain how pycharm works

This link will help you to create a pycharm project – https://www.jetbrains.com/help/pycharm/creating-and-running-your-first-python-project.html#creating-simple-project

Once you are done opening your project launch – settings

go to Python Interpreter

open Show All

click the plus symbol

System Interpreter and then select 3 dots

you need to look for – C:\Program Files\Autodesk\<maya version>\bin\mayapy.exe

press ok and ok

You should be back on this dialog box – you should notice Python 3.10 (2)

Select show interpreter paths – https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-reloading-interpreter-paths.html

click the plus sign and open the path from devkitBase – C:\Program Files\Autodesk\Maya2020\devkit\devkitBase\devkit\other\pymel\extras\completion\py

Remove site-packages there is a possibility it might conflict with our completion path

ok and ok

Go back to Settings dialog box and type – external documentation

click the plus symbol

Module Name: maya.cmds

URL/Path Pattern: http://help.autodesk.com/cloudhelp/2024/ENU/Maya-Tech-Docs/CommandsPython/{element.name}.html

ok and ok

below is the final result, enjoy doing autocomplete😁

Honestly thanks to the below links for doing the heavy duty.

Helpful links worth the read

https://matiascodesal.com/blog/how-to-setup-pycharm-for-maya-scripting-with-autocomplete-and-external-documentation/

https://dev.to/chadrik/pymels-new-type-stubs-2die

https://forums.autodesk.com/t5/maya-programming/maya-2023-devkit-missing-pymel-completion-stubs/td-p/11464367

How to parent Qt widget with maya – Windows

Hello All,

This a very small issue mostly windows people come across while using Qt.

Basically If you have created a widget in designer(assuming person knows how to use Qt Designer),

converted with command line or from inside of maya to python (ui to py) – output_2.py

to inherit the output_2.py class in another class.

Please check the below approach and this should come in handy.

Non-Parented version of ui

import sys
sys.path.append("D:\\All_Projs\\Qt_Designer_Proj\\ui_to_maya_testing")
from output_2 import Ui_Form
from PySide2 import QtWidgets
from PySide2 import QtGui

class Trial(QtWidgets.QWidget):
    def __init__(self):
        super(Trial, self).__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)

window = Trial()
window.show()
2 tabs for non parented ui (in the bottom)

Parented version of ui

from PySide2 import QtCore, QtGui, QtWidgets
import sys
sys.path.append("D:\\All_Projs\\Qt_Designer_Proj\\ui_to_maya_testing\\")
from output_2 import Ui_Form
import maya.OpenMayaUI as omui
from shiboken2 import wrapInstance


ptr = omui.MQtUtil.mainWindow()
ptr_instance = wrapInstance(long(ptr), QtWidgets.QWidget)


class Widget(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(Widget, self).__init__(parent)
        
        self.setParent(ptr_instance)
        self.setWindowFlags(QtCore.Qt.Window)
        
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        
        

def main():
    app = Widget()
    app.show()

main()
no tabs for non parented ui (in the bottom)

This is one of the approach that i am aware of, i had read it on a site, but I lost the site. If you have any other approach do let me know.

Have a Qt day.

Controller Storage: Sales Status

Hello All,

I had created a tool Named Controller Storage in Year 2020, and then in 2021 I updated the tool and TRIED selling it for 2$, What happened?

Sales of the Tool

One of the coolest website

Animprops – https://animprops.com/

One of the dumb sites

Gumroad – bloody can’t even find my own tool, forget it and very complicated. If anyone interested to help me ping me in the comments.

Free Version

Controller storage FREE version sold 45 times From July 2020 to September 2022 , thanks to all of the people those who have tried it.

Paid Version

The paid version did not sell at all, 2$ for a tool was an expensive deal lol.

I did a Survey from the people/artists who purchased the free version, to understand the requirements and if they will pay for the tool or not, I got tremendous amount of feedback – 2 🤣.

I was seeking for some answers to improve, so i came across Autodesk forums – And I received really good constructive criticism – and I know people are not going to click to the link 😁 – so below is the message

https://forums.autodesk.com/t5/maya-programming/controller-storage-tool-feedback/m-p/10965413/highlight/true#M15038

from Today onwards I have made the updated tool free as well.

Analysis

So as per me the tool is a hit, I was not expecting more than 1 person(that is me)to use it. Experiment of keeping the paid product in the market helped me understand certain things, eg: asking questions, survey’s, updates, at what point one should make tools paid, etc. These are few of them I need to work on from next time. Hopefully I’ll come with a better update for the tool next time, lets see 😄.

That’s all for Today.

Maya: userSetup – execute commands whenever Maya startsup

Hello All,

I was setting up userSetup the mel edition in my company and I instantly realized it was not a trivial task. And the below video covers most of the heavy duty, please check it out.

Since the world has moved on to Python, we should have an example of python as well. Maya docs was kind enough for not giving any info on either of them(Well you’ll get my rant once you watch the above video lol).

Maya userSetup.mel ticket

to check the path from userSetup.mel is being executed

whatIs userSetup.mel
// Result: Script found in: C:/Users/ADMIN/OneDrive/Documents/maya/2020/scripts/userSetup.mel // 

whatIs command wont help in finding userSetup.py

#command can help you find yours scripts directory
print cmds.internalVar(userAppDir=True)

#save below script in userSetup.py to the path that you get from above command.
import maya.cmds as cmds
def dosomething():
    cmds.grid(spacing=100)
cmds.evalDeferred('dosomething()')
print("this is a test")

Maya userSetup.py – where to place the file?

In windows 10 – “C:\Users\ADMIN\OneDrive\Documents\maya\2020\scripts\userSetup.py”

grid spacing changed to 100

Give it a try.

Unreal: Heads to Foot to Cm

Hello All,

Keeping it short this time.

Table of Contents

Dcc used to execute the tasks
Heads and Cubes in Unreal for RTS Reference
Brevity Resources

Dcc used to execute the tasks

Maya2020, Unreal 4.26.2

Plugins: Perforce VCS-P4V, P4GT for Maya, Unreal 3dTextBeta

Brief Context

Maya is a 3d software I used to create cubes Intentionally

Unreal for testing the camera distance for each character height

Perforce – P4V – version control system for home work or if one wants to share depot with multiple artists(haven’t tried yet ) is by far one of the amazing tool.

P4GT for Maya is from P4V family, will help you save your increments in the depot

for more details — https://community.perforce.com/s/article/2552

Unreal 3dTextBeta is a text plugin for text(lol)

Heads and Cubes in Unreal for RTS Reference

Some great examples

World or warcraft

Rise of Nations

Age of empires

Fieldrunners

FrostPunk

Dota

etc.

Brevity Resources

You’ll find my verbose work – My Trello Board

How to Create 7ft in DCC instead in Unreal

Unreal and Maya unit setup = cm

how to create 8heads in maya for reference
create 7ft cube in maya
to create 7ft cube– change the unit setup in maya to foot, adjust 7ft height in cube settings.(or directly convert foot to cm from google)
change back the maya unit setup to cm
now the foot has changed to cm in cube settings
to get the sphere radius from 7ft — divide the cm by 2 — 7ft = 213.36cm
213.36cm/2 = 106.68cm
apply 106.68cm in the sphere radius(this is a base value, after this divide by 8)
for 8 spheres — 106.68cm/8 =13.335
increase the cube height subdivisions to 8

now unreal
as per unreal — mannequin model is considered as base height
that is 6ft approx or 180cm
https://www.worldofleveldesign.com/categories/ue4/ue4-guide-to-scale-dimensions.php

reference notes
https://www.worldofleveldesign.com/categories/ue4/my-system-project-set-up-mayalt-maya-ue4.php
https://github.com/Allar/ue5-style-guide
https://blog.kongregate.com/design-tips-for-in-game-character-proportions/
https://sciencing.com/calculate-circular-area-7411839.html
https://www.youtube.com/watch?v=QCdFBzUwoF0
https://www.creativecomicart.com/measuring-human-proportion.html
https://www.restaurantnorman.com/how-tall-is-8-heads-high/

How to snap gizmo to polygon face in maya

http://patrickvfx.blogspot.com/2016/09/finding-centre-position-of-polygon-face.html
https://groups.google.com/g/python_inside_maya/c/UoMVxr0deVo/m/OJ2K8IpevxQJ
https://mayastation.typepad.com/maya-station/2009/11/where-is-the-center-of-a-polygon.html

Well this is it for today people. Have a great weekend!!

PySide2:Resource Compiler(avoid using file paths to use images in widgets)

Hello Guys,

When we start new, we explore a lot and land up with a technique that works for us.

But that does not mean it is one of the most efficient technique, this post is about one of those, that i got to learn from Qt forum guys.

Resource Compiler/Qt Resource System to store images

Verbose stuff

https://doc.qt.io/qtforpython/overviews/resources.html

For technical details you can read the above docs, it covers a lot of things except the approach to execute the whole process.

Why do we need this process?

This process bakes your images to a binarydata.py and you can use the binarydata.py in the ui base class (a file that one converts from ui to py using uic)instead of using a folder path to load the image. This is a very neat approach.

Requirements

  • Autodesk Maya(not necessary)
  • PySide2/PyQt5
  • Qtdesigner/designer
  • Windows

So the cool part

  • Create a new_folder in any drives
  • copy your images in the new_folder
  • open designer/qtdesigner
  • create widget
  • Create label/drag and drop label in the widget
  • in the property_editor filter pixmap
  • Select the pencil in the Resource Browser
  • right click in the right hand side
  • create a new .qrc file in the new_folder
  • in the left hand side create a new prefix
  • below in the lhs panel there are three button select the add files(middle button)
  • select the image you pasted earlier in the new_folder
  •  double click the pixmap and got to corner “…”(three dots)
  • select the resources and the image and the image will be displayed
  • avoid giving test names to any files, as the editors recognize it as a test module and creates name conflicts
  • great part 1 is done

now its time to convert the .qrc to .py

Please read carefully from here on wards, everything gets messy

  • open a terminal/command prompt/powershell
  • drag “C:\Program Files\Autodesk\<maya_version>\bin\rcc.exe” <file_path>/file.qrc -o <file_path>/file.py — there is a chance it might convert to c++ version, check the .py file that the above command line creates
  • if maya rcc.exe behaves unusual by giving you c++ output, You’ll need PySide2
  • maya is not the only one who behaves unusual python too — PySide2 Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.10 (it means more than 3.5 smaller or equal to 2.7)
  • so that is a trouble, please then install python 3.8(even though it tells 2.7 please avoid, its troublesome)
  • python -m pip install PySide2 (later you can uninstall it)
  • below are the alternatives in case you face any errors, always check the “–help” of the command line
  • C:\Python38\Lib\site-packages\PySide2\rcc.exe -g python2 <file_path>/file.qrc -o <file_path>/file.py
  • C:\Python38\Scripts\pyrcc5.exe
  • C:\Python27\Lib\site-packages\PyQt4\pyrcc4.exe
# Resource object code (Python 2)
# Created by: object code
# Created by: The Resource Compiler for Qt version 5.15.0
# WARNING! All changes made in this file will be lost!

from PySide2 import QtCore

qt_resource_data = "\
\x00\x00\xcf\x14\
\xff\
\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x00\x00\
\x00\x00\x00\xff\xe1\x00\x16Exif\x00\x00II*\
\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xdb\x00C\x00\
\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x02\
\x01\x01\x01\x01\x01\x02\x01\x01\x01\x02\x02\x02\x02\x02\x02\x02\
\x02\x02\x03\x03\x04\x03\x03\x03\x03\x03\x02\x02\x03\x04\x03\x03\
\x04\x04\x04\x04\x04\x02\x03\x05\x05\x04\x04\x05\x04\x04\x04\x04\
\xff\xdb\x00C\x01\x01\x01\x01\x01\x01\x01\x02\x01\x01\x02\x04\
\x03\x02\x03\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\
\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\
\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\
\x04\x04\x04\x04\x04\xff\xc0\x00\x11\x08\x02\x1c\x03\xc0\x03\x01\
\x22\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x1f\x00\x00\x01\x05\
\x01\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\
\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\xff\xc4\x00\xb5\x10\x00\x02\
\x01\x03\x03\x02\x04\x03\x05\x05\x04\x04\x00\x00\x01}\x01\x02\
\x03\x00\x04\x11\x05\x12!1A\x06\x13Qa\x07\x22q\
\x142\x81\x91\xa1\x08#B\xb1\xc1\x15R\xd1\xf0$3\
br\x82\x09\x0a\x16\x17\x18\x19\x1a%&'()*\

What works for me

I convert it through

C:\Python27\Lib\site-packages\PyQt4\pyrcc4.exe -py2 <file_path>\head_banner.qrc -o <file_path>\head_banner.py

and open the .py file and edit the PyQt4 to PySide2, as you can see below.

# -*- coding: utf-8 -*-

# Resource object code
#
# Created: Fri 17. Sep 22:43:20 2021
#      by: The Resource Compiler for PyQt (Qt v4.8.4)
#
# WARNING! All changes made in this file will be lost!

from PySide2 import QtCore

The output

below code is a an example of maya. I am not using an image path as you can see it is a resource. When you use a class you can keep your rcc file in the package folder and just import that and provide your qrc file prefix and you are good to go.

from PySide2 import QtWidgets
from PySide2 import QtGui
import sys
#sys.path.append('D:\\All_Projs\\Qt_Designer_Proj\\untitled')
import head_banner#rcc
#reload(head_banner)

def label():
    win_wid = QtWidgets.QWidget()
    label = QtWidgets.QLabel()
    image_pixmap = QtGui.QPixmap(":/head/progress_01.jpg")
    label.setPixmap(image_pixmap)
    layout = QtWidgets.QVBoxLayout()
    layout.addWidget(label)
    win_wid.setLayout(layout)
    win_wid.resize(200, 50)
    
    return win_wid
    
trial = label()
trial.show()

Try it out guys.

Take care bye!!

Maya: How to add shelf to env?

Hello guys,

The below mentioned link is the reference link to add shelf path to the Maya.env,

Setting environment variables using Maya.env

This is for windows,

steps,

(Note: Documents path is the path that comes in the right hand side of the explorer)

  1. create a folder in any drive path: D:\All_Projs\Maya_Projs\shelves
  2. open maya create a new shelf named: test, save all the shelves(assuming the user is familiar with maya)
  3. go to path C:\Users\ADMIN\Documents\maya\version\prefs\shelves
  4. cut your shelf: shelf_test.mel
  5. and paste it to created folder from point 1
  6. go to path: C:\Users\ADMIN\Documents\maya
  7. create a file named Maya.env or if its created just open it in any text editor
  8. you need to create a shelf variable and paste the path like this : MAYA_SHELF_PATH = D:\All_Projs\Maya_Projs\shelves\;
  9. and save it
  10. open maya and check the shelf
  11. with this just create your custom shelf and keep saving them in the same folder
  12. there is a possibility that you might get an error in the maya output window on the top as fatal error, then kindly check the path if it exists or not

Thank You

If you face any problem let me know on bghuntla123@gmail.com