cvShapeInverter

Fork me on GitHub

Direct download

Description

A script and deformer that can invert a shape through a deformation chain so the shape can be applied as a front of chain shape. This has the same functionality as Christian Breitling’s correctiveShape plug-in. He stopped providing it after Maya 2008 so I’m providing a Python version that doesn’t need to be compiled.

Installation

cvshapeinverter is a Maya module that can be installed like all other Maya modules. You can do one of the following:

  • Add the cvshapeinverter root directory to the MAYA_MODULE_PATH environment variable.
  • Add the cvshapeinverter root directory to the MAYA_MODULE_PATH in your Maya.env. e.g. MAYA_MODULE_PATH += /path/to/cvshapeinverter
  • Edit the cvshapeinverter.mod file, and replace the ./ with the full path to the cmt root directory, then copy the cmt.mod file to where your modules are loaded from.

Usage Notes

Pose your skinned model in the pose that you want to correct. Duplicate the mesh and sculpt in your fixes. Select the original skinned model, shift select the corrected model and run:

import cvshapeinverter
cvshapeinverter.invert()
An inverted shape will be generated which you can then apply as a front of chain blendShape target. The generated shape will have a live deformer affecting it so edits you make on your corrected mesh will be inverted through the deformer.

56 thoughts on “cvShapeInverter”

thematt March 3, 2011 at 11:38 am

great Chad! was waiting for someone to rebuild that tool, it’s really usefull!! thanks a lot!

cheers

Fed March 17, 2011 at 10:08 am

Great job Chad! You rock as usual

dbokser March 23, 2011 at 4:13 pm

Thanks a lot for this! Found this through the link on Scott’s site. I’ve repurposed Christian’s MEL script into a Python version, and I’ve been meaning to turn it into a deformer but haven’t had the time. Thanks for making this!

steph April 20, 2011 at 10:19 pm

thanks Chad. I have some troubles trying to install .Do a i to declare environment variable name PYTHONPATH ? the Maya scripts directory is the one in My documents/Maya/…? What version of Python? 3.2?.

steph April 20, 2011 at 10:38 pm

Hello.I install python3.2 and create a environment variable name PYTHONPATH (my documents\maya\2011-x64\script . Then i put your __init__ file in it, and put the file cvShapeInverter in Maya\2011\bin\plug-ins\ directory. I can see and load the cvShapeInverter.py plugin in the Plug-in Manager.
I first select the original skinned model, shift select the corrected model and run:
import cvShapeInverter
cvShapeInverter.invert()

Maya tell me:
# Error: AttributeError: ‘module’ object has no attribute ‘invert’ #

mantrid May 26, 2011 at 4:54 am

Hi Chad,
Cheers for this, an AMAZING helping hand it is. Only one problem…I can’t seem to get it working properly. When I select the skin mesh and shift-select the sculpted mesh and run the ocmmand, this is what I get :
# Error: ValueError: More than one object matches name: pasted__pasted__pasted__polySurfaceShape1 #

Andy July 3, 2011 at 1:25 am

Chad, this is incredible!
Barely blinked on 60k faces.
Thanks so much!!

MostVicious October 8, 2011 at 5:08 pm

Hello chad and thanks for release this great tool, so i have i little error when i try to execute the command, i dunno what i do wrong but, i put the files like you explain in my directory , load the plugin in plugin windows of maya, i pose my model create a new mesh whit some fixes but when i try to run the command i have this message error : # Error: ImportError: No module named cvShapeInverter

Chad October 9, 2011 at 12:36 pm

You have to make sure your scripts directory is in your Python path.

charliewales October 28, 2011 at 8:59 am

What can I say but thanks so much for this awesome plugin!

Deocliciano February 25, 2012 at 9:33 am

Thank you very much!

Works well on my iMac.

sulkybunny March 20, 2012 at 11:34 am

Hi there

the script works very well.. but i just had tried it on a hand model and i get this error.. can u guess whats it about? i am using the new weight blended skinning in 2011

Error: ValueError: invalid null reference in method ‘MSelectionList_add’, argument 2 of type ‘MObject const &’ #

Timm March 27, 2012 at 9:18 am

Hey Chad, awesome script!
Always worked properly except for the latest char. i’m rigging. I select the skinned mesh, shift select the sculpted one and execute the script:
import cvShapeInverter
reload(cvShapeInverter)
cvShapeInverter.invert()

I get this error:
# Error: RuntimeError: (kInvalidParameter): Object does not exist #

Any idea what the cause might be and how to fix it?

Gordy April 9, 2012 at 9:43 pm

Chad…. well played. I needed this and you provided. I want to give you a baby.

djx May 9, 2012 at 7:23 am

Thanks Chad. Just found this. Works nicely in 2013 – except for one thing… MStatus is nolonger in OpenMaya. My quick fix was to make 2 edits in cvShapeInverter.py and replace “return OpenMaya.MStatus.kSuccess” with “return 0” (no quotes).

David

chrisg June 3, 2012 at 6:50 pm

Hi Chad,

Brilliant script. I love it. I’ve modified the getShape method to help with dagpath names on shapes, and also ignoring intermediate shapes, as follows:

def getShape(node):
if cmds.nodeType(node) == ‘transform’:
shapes = [x for x in cmds.listRelatives(node, shapes=True, fullPath=True) if cmds.getAttr(x + ‘.intermediateObject’) != True]
if not shapes:
raise RuntimeError, ‘%s has no shape’ % node
# end if
return shapes[0]
elif cmds.nodeType(node) in [‘mesh’, ‘nurbsCurve’, ‘nurbsSurface’]:
return node
# end if
# end getShape

Angelo June 10, 2012 at 10:53 am

Hey Chad, I’ve been trying for hours and hours to get this plug-in to work to no success. it errors and gives me this:

# Error: AttributeError: file line 2: ‘module’ object has no attribute ‘invert’ #

I downloaded the zip file, placed the src items into my maya>bin>plug ins folder and the scripts items into my maya/scripts directory. still no luck.. any suggestions?

Angelo June 14, 2012 at 2:44 pm

Ok I ran into this problem.. any help?

# Error: RuntimeError: file c:\buildforge\Maya_2013_Win64\build\wrk\optim\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 9957: (kInvalidParameter): Object does not exist #

Chris Dardis August 23, 2012 at 7:54 pm

Hi Chad,

I am really having a hard time getting this up and running. I have placed the ,txt in the modules folder and added my path. The contents of the zip file have been copied to the plugin folder (Maya2012\bin\plug-ins\cvShapeInverter).

I have set a plugin path in my maya.env;

MAYA_PLUG_IN_PATH = C:\Program Files\Autodesk\Maya2012\bin\plug-ins\cvShapeInverter\src

import sys
for path in sys.path: print path

returns a path;
C:\Program Files\Autodesk\Maya2012\bin\plug-ins\cvShapeInverter\scripts

which seems correct to me.

Despite this, I get;

# Error: line 1: ImportError: file line 1: No module named cvshapeinverter #

Am I missing something fundamental? Thanks, Chris

yoon seok September 16, 2012 at 7:16 pm

Hi Chad,

I am really having a hard time getting this up and running. I loaded cvShapeInverter in maya plugin Manager
and when I run this script
import cvShapeInventer

I got this message
#Error : ImportError : No module named cvShapeInverter #

yoonseok October 12, 2012 at 12:13 am

I solve the problem . it’s awesome plugin . god bress you ,

jroot November 27, 2012 at 2:15 pm

Script is working well, all is good. You rule.

There is just one thing

I have an arm, and two sculpts for that arm. Each sculpt was done from a bone pose. PoseA is about a 90 bend of the elbow and poseB is something like 150. The initial work flow was to run the script on both poses, add poseB as a blend shape and then poseA as an in-between. However, the game engine doesn’t understand in-betweens and I guess thats not changing.

So, I’d like to be able to add poseA as a blend shape. Then set the skinned mesh + poseA blend shape into poseB and have the script return a shape that gets me to poseB as additive to poseA. However the script doesnt appear to see that there is a blendshape active when it computes the corrective.

Maybe I am doing something wrong?
Maybe this is not implemented?
Maybe I am SOL?

jroot November 27, 2012 at 3:09 pm

Update:
If we take the corrective of poseA and bind to the skeleton, copy weights in by vert order and then apply the bone pose to set us into poseB we can generate a corrective for poseB that seems to work additively to poseA. This allows us to circumvent in-betweens.

Sweet!

Chad November 27, 2012 at 4:06 pm

You could also update the script to subtract out the active blend shape deltas once they have been inverted.

utpal bhatt August 21, 2014 at 5:31 am

Hi Chad,
Thanks a lot for the script. It is an excellent script, once you know how to make it work.
In the beginning, I could not get proper corrective shapes from the script. The script was creating improper inverted shapes at first.
After a few trials I could make it work successfully and I thought I might share my findings with other users here.
1. If the skinned geometry is referenced, the script will not work. Import the geometry into your file by “file>Import Objects from Reference” in the Reference Editor
2. When you duplicate your mesh in pose to sculpt in your fixes, Do Not delete the hidden intermediate mesh node that gets duplicated (named something like: xyz1ShapeOrig)
3. Before running “cvShapeInverter.invert()” command, remove any incoming Blendshapes to your skinned characters.
Once I made sure of these few things, my corrective shapes came out without any problems.
Again, thanks a lot for an excellent script. It made my job much much easier.

-utpal

Enrico October 21, 2014 at 3:26 am

Hi Chad,
thanks for sharing this plug-in, I’m trying to use it in Maya 2015 and thanks to the help of utpal bhatt and djx I have been able to make it work but… the inverted mesh created is just like the normal mesh in bind pose… any guess to what could be my problem?
I duplicate and modify the mesh before running the script of course
using normal smooth bind skinning
thanks again
Enrico

ekunzendorf October 21, 2014 at 4:24 pm

Getting this problem on a mac:
# Error: line 1: AttributeError: file line 2: ‘module’ object has no attribute ‘invert’ #

I have the script in my Library/Preferences/Autodesk/maya/2015-x64/scripts folder as well as in my /Users/Shared/Autodesk/maya/plug-ins

Any ideas?

Chad October 22, 2014 at 9:14 am

Make sure you don’t have the files switched around. The one in the scripts folder shoulder have a line that says

def invert()

quentoon December 12, 2014 at 11:23 am

Hi Chad, thanks so much for this script and plugin.
Unfortunately I encounter the same error than Timm above,
I get this error:
# Error: RuntimeError: (kInvalidParameter): Object does not exist #

Any clue ?

José March 20, 2015 at 2:15 am

Hey, can you tell me the folder path on maya, I have the cvshape in my 2015 plugin window, means that Maya does read it, but I can’t seem to import it with the command. Apparently the __init__.py is not where it is supposed to be right? Please help…

José March 24, 2015 at 12:26 am

OK, MAC users here’s what you do, because this has haunted my dreams for a while now, and when I found the answer, I just bursted with happiness and rainbows.

SOME FOLDERS ARE HIDDEN ON A MAC, so go to terminal type in: defaults write com.apple.finder AppleShowAllFiles YES.

click enter, then right click the Finder icon and click Relaunch.
add the contents of scripts into Users/YOURNAME/Library/Preferences/Autodesk/Maya/2015-64/scripts

then add the contents of src into Applications/Autodesk/maya2015/Maya.app (YOU RIGHT CLICK THE MAYA ICON AND HIT SHOW PACKAGE CONTENTS)/Contents/MacOS/plug-ins

NOW you can search in the plug-in Manager for cvshapeinverter.py, click load, then type in the Python command and live happily for ever after.

outbred May 14, 2015 at 6:18 am

hey i see you have up dated it for maya 2016, i pretty new to this and the new instructions seem confusing could i ask for a more detailed breakdown of how to install please

thanks heaps

john June 19, 2015 at 8:37 am

Just a heads up, in the instructions the Python file name is different than the import command. Probably leading to a few errors people are reporting with the module not found.

Chad June 20, 2015 at 11:14 am

Thanks for the heads up!

john June 20, 2015 at 11:45 am

No prob. Great script! Saved my bacon a few times.

james December 21, 2015 at 4:33 am

Very useful.

Thanks!

James

Lucie February 2, 2016 at 3:11 am

Hello Chad,
I’ve used the CV shape inverter quite a few times, and it is always working great. but this morning on a shape this error message appeared : cv shape inverter Object is incompatible with this method

any idea where it comes from ? the meshes are absolutely similar…

Chad February 4, 2016 at 10:48 pm

hmmm…I’m not sure. Can you send me a scene to look at? chadvernon at gmail

Martin February 8, 2016 at 7:00 am

Hey there! I really love that plugin, unfortunately lately, I’ve got an error too, which looks similar to the one Lucie got :

// Error: RuntimeError: file S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 3027: (kInvalidParameter): Object is incompatible with this method

Any clue how to solve this? would be really helpful!

Martin February 8, 2016 at 10:45 am

Actually I found the solution, I’m using 2 other plugins (ngSkinTools) to skin and to create my blendshapes (DPK_bcs). The first one caused this error, and the second one, made the shapeinverter create wrong corrective shapes. I transfered my skin onto the maya skin tool, and deleted my blendshapes and it works better, but I’ve a lot more manipulation to do this way ^^’

Mitch May 10, 2016 at 4:13 am

Dear Chad,

Great tool!
cvShapeInverter is indispensable to our pipe.

But…
As most/all ‘inverters’ it only ‘inverts’ skinCluster deformers. Adding Blendshape Deformers was quite easy. But for other deformers (Non-Linear, Ffd, DeltaMush, etc…) it’s a different story… (to my knowledge, only SoftImage provides this out of the box))
The big advantage of cvShapeInverter is that the result-shapes stay connected to the sculpt-shapes.
We’ve coded some stuff to ‘invert’ every kind of deformer but, unlike cvShapeInverter, the resulting shapes aren’t connected anymore.

Chad also brought us cvWrap, a lightning fast wrap deformer that works 10x better than the native maya wrap deformer. And huray!
As stated on the Guithub page (https://github.com/chadmv/cvwrap), cvWrap supports inverted front of chain blendshapes!

But how can we set up cvWrap to produce the same results as cvShapeInverter (aka cvSkinClusterInverter)?

Robin May 18, 2016 at 2:19 pm

Hi Chad, same problem here :
// Error: RuntimeError: file S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 3074: (kInvalidParameter): Object is incompatible with this method //
Like Martin, I’m using ngSkinTools but not DPK_bcs.
Do you have an idea to fix that issue whitout the heavy process explained by Martin?

Dario Guderian May 31, 2016 at 12:56 pm

Can you help me with an ERROR
Maya always telling me that i have more than one object matches name: polySurfaceShape1
I don’t know what to do

Mike June 6, 2016 at 10:49 am

I’m getting a similar error to Martin’s, but I’m unable to fix the problem. We’re using a different studio’s workflow which requires us to make one-off blendshapes on the completed rigs if we wan’t to adjust a pose. Due to volume and time constraints, Martin’s suggestion won’t cut it :/

This is the error:
// Error: (kInvalidParameter): Object is incompatible with this method
# Traceback (most recent call last):
#  File "...hidden folder dir.../shapeInverter.py", line 26, in deform
#     run = data.inputValue(shapeInverter.aActivate).asBool()
#   File "S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py", line 3074, in inputValue
# RuntimeError: (kInvalidParameter): Object is incompatible with this method //

I’m not experienced with this type of coding so I’m not really sure how to fix this.

Chad June 15, 2016 at 10:10 pm

@Mitch With cvWrap you should be able to treat things the same as if they were skinned.

@Everyone else:
I’ve pushed up some updates, give it a try. If someone wants to send me a scene with the ngSkinTools error, I can troubleshoot it if it’s still an issue.

Alex July 4, 2016 at 11:17 am

Firstly, thankyou for writing this wonderful script.

Secondly, I also have the error that other people seem to be getting, any ideas?

file S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 3027: (kInvalidParameter): Object is incompatible with this method

Alex July 11, 2016 at 1:00 pm

Chad, thanks for the update – problem solved!

Kevin September 12, 2016 at 6:52 am

thank you so much for the update – same problem for maya 2016 solved, thanks again!!!

john May 26, 2017 at 12:46 pm

Hi Chad,

Getting this error. I got latest version:

# Traceback (most recent call last):
# File “”, line 2, in
# File “C:/Users/Johnny2/Documents/maya/2016.5/scripts\cvshapeinverter.py”, line 117, in invert
# cmds.setAttr(‘%s.activate’ % deformer, True)
# RuntimeError: setAttr: No object matches name: cvShapeInverter1.activate //

I looked at that line in the code, and that’s the only reference to the “activate” attr in there. Is there something else I’m missing? The shape seems to make itself ok, but I’m just getting that error. It’s at the end of the method so seems innocuous.

Thanks again for the tool!

John

Leave A Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

<code> For inline code.
[sourcecode] For multiline code.