Sunday, July 28, 2019

Maya 2018 Auto Retopo Function

I just found this handy hidden function in Maya 2018 to turn your Mesh into even Quads or Triangles.

// MEL
// turn selected mesh into even quads
// turn selected mesh into even triangles

A video explaining the attributes to adjust here

Thursday, August 23, 2018

Get object type

# To query the type of an object:
pm.objectType( 'sphere1Shape' )
# Result: u'nurbsSurface' #

# To confirm that sphere1Shape really is a nurbs surface:
pm.objectType( 'sphere1Shape', isType='nurbsSurface' )
# Result: True #

Wednesday, August 15, 2018

Debug in Maya with Visual Studio Code

Working on more complex scripting projects in Maya, the time spent debugging grows. Time is precious and having a clean debug workflow is the big bang here. I switched to VS Code recently and found setting up the Maya debugging connection quite simple, thanks to this great blog post by iwonderwhatjoeisworkingon

Sunday, July 8, 2018

Image Plane Manager

After using this tool for Animation and Layout for many years, I finally cleaned it up and put it up on Highend3d for the community. Free version:

Sunday, August 27, 2017

Print Infos Warnings Debug that is better than print

Print 'Done'. print 'value is 10'.. so many prints and those make script slow and take long to clean up once we done debugging. So i've been going slowly to other, I find better solutions to debugging and showing infos to unser.

>>> 1  Showing infos to user.
There are three types of infos we can print directly into the Maya Status Line. So User has no need to open script editor to see the note.

pm.error('This will be printed as error in in Status line')
pm.warning('This will be printed as warning in in Status line')
pm.displayInfo('This will be printed as info in in Status line')

>>> 2. Debugging
Logging is great because we can choose between different levels and can turn them off/on for the entire file by modifying one line

# set up
_logger = logging.getLogger(__name__)

# set level

# throughout the script - logg

_logger.warning('There is a odd value returned %s'%value)'IK switch0isfk is %s'%switch0isfkTfb        )

_logger.debug('snapping slaveDup')

# to turn / on

logger.disabled = False

LevelWhen it’s used
DEBUGDetailed information, typically of interest only when diagnosing problems.
INFOConfirmation that things are working as expected.
WARNINGAn indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected.
ERRORDue to a more serious problem, the software has not been able to perform some function.
CRITICALA serious error, indicating that the program itself may be unable to continue running.

Monday, July 31, 2017

Some interesting Pymel Attribute Functions

Returns true if the plug’s value is allowed to be set directly. A plug isFreeToChange if it is not locked, and it is not a destination or if it is a destination, then it must be a special case (such as connected to an anim curve).
checkParents : bool
Check parent plugs.
checkChildren : bool
Check child plugs.
Return type:

This method determines whether this plug came from a referenced file. A plug is considered to have come from a referenced file if it is connected and that connection was made within a referenced file.
Return type:bool

Return the total number of connected element plugs belonging to this array plug.
Return type:int

connected element plugs belonging to this array plug.

Sunday, July 2, 2017

Vectors in Maya 2: Nodes

When using Vector Match in Rigs, we need life update. Creating custom Maya nodes can be done via API scripting but Maya comes with a number of built-in Vector Nodes we can use (even sometimes with a workaround)

Define the objects

obj1, obj2 = pm.PyNode('locator1'), pm.PyNode('locator2')
# see how i connect the objecsts at the end

# Normalize

Maya hs node vectorProduct, if we set it to Operation 'None' and Enable 'Normalize' it simple acts as a normalize

normalizeNode = pm.createNode('vectorProduct')

# Scale to any length, Lock in one axis if needed

multiplyNode = pm.createNode('multiplyDivide')

# connect nodes
obj1.translate >> normalizeNode.input1
normalizeNode.output >> multiplyNode.input1
multiplyNode.output >> obj2.translate

# Vector Magnitude (length)

To get a vectors length in Maya we 1. normalize it and 2. create dot product of normalized and non normalized

obj1, obj2 = pm.PyNode('pSphere1'), pm.PyNode('pSphere2')

# normalize node
normalizeNode = pm.createNode('vectorProduct')

# vector length node
dotNode = pm.createNode('vectorProduct')

# connect
normalizeNode.output >> dotNode.input1
obj1.t >> dotNode.input2
dotNode.output >> multiplyNode.input1

Syntax Highlighting in Blogger

Had to stop here figure out how to Blogger can deal with syntax highlight first before writing this first blog. Here is the step by step guide i used to get it to work in a few minutes.

Vectors in Maya 1: OpenMaya

If you using aim/point constraints in Maya, you are not using a combination of Vector and Trigonometry calculations under the hood the software does for you. Using Vector math directly can allow you to work not only smarter but also faster and easier, once you get hang of it.

If you aim to do some calculation using Vector math in Python, scripting to get a value is probably the fastest way. However, if you want to implement Vector math into your Rig, we can use do the same calculations using Nodes (Expressions would be another alternative, but I avoid using those).

This post discusses using OpenMaya MVectors class.

# Creating MVectors in Maya

import pymel.core as pm
import maya.api.OpenMaya as om
import math
obj1, obj2 = pm.PyNode('locator1'), pm.PyNode('locator2')
v1, v2 = om.MVector(obj1.t.get()), om.MVector(obj2.t.get()

# Length

Uses - Distance Between two Points


# Normalize

The Vector direction at a length of one. This normalizes the Vectors,
Uses - make comparisons based on direction only.


# DOT Product / Angle Between Two Vectors

The Dot product multiplies two vectors and returns a Scalar number (no Vector).
If we normalize one Vector, returns a number between 0 and 1

> very useful to calculate Angles between Vectors, see if they face the same direction, etc
> find out what angle something is pointing

dot = v1*v2 # returns degreee in radiants
dot = v1*v2.normal() # returns value between 0 and 1, 0=parallel
print om.MAngle(math.acos(dot)).asDegrees() # returns the degree

Source and Resources:
Short overview of MVector operations

Maya 2018 Auto Retopo Function

I just found this handy hidden function in Maya 2018 to turn your Mesh into even Quads or Triangles. // MEL //  turn selected mesh int...