Import blendShape attribute map

681 views
Skip to first unread message

Aren Voorhees

unread,
Sep 12, 2017, 5:59:20 PM9/12/17
to Python Programming for Autodesk Maya
Hello all, 

I'm trying to import a blendshape attribute map from a texture file.  I expect I must be going about it the wrong way though as I can't seem to get it to work no matter how I try it.  Here is what I'm doing currently:

import maya.cmds as cmds

cmds.artAttrPaintVertexCtx('artAttrBlendShapeContext')
ctx = pm.currentCtx()
cmds.setToolTo(ctx)
cmds.artAttrPaintVertexCtx(ctx, ifl='P:\BsMaps\half_l.tif', importfilemode='luminance')

I'm getting this:

// Error:

# Traceback (most recent call last):

# File "<maya console>", line 2, in <module>

# RuntimeError: //



If anyone has done this before, or knows what I'm doing wrong, a hint would be amazing!  

Thanks

Simon Anderson

unread,
Sep 12, 2017, 7:04:42 PM9/12/17
to Python Programming for Autodesk Maya
Hi Aren,

Just from first glance, it looks like your path is incorrect. Remember to use \\ when using strings in Python.
 ifl='P:\\BsMaps\\half_l.tif'

in the code above you have pm, not sure what that variable is meant to be in your example


Tests I got working:

# export
# I had the UI tool open
import maya.cmds as cmds 
ctx = cmds.currentCtx() # Result: artAttrColorPerVertexContext # 
cmds.artAttrPaintVertexCtx(ctx, e=True, exportfilesave='//home//users//simonan//half_l.tif', importfilemode='luminance')

# import file
# I had the UI tool open
import maya.cmds as cmds
ctx = cmds.currentCtx() 
cmds.artAttrPaintVertexCtx(ctx, e=True, importfileload='//home//users//simonan//half_l.tif', importfilemode='luminance')

Docs dont have an e variable in them, but the e seems to make it work.

I hope that helps

Justin Israel

unread,
Sep 12, 2017, 9:26:00 PM9/12/17
to python_in...@googlegroups.com
On Wed, Sep 13, 2017 at 11:04 AM Simon Anderson <simonben...@gmail.com> wrote:
Hi Aren,

Just from first glance, it looks like your path is incorrect. Remember to use \\ when using strings in Python.
 ifl='P:\\BsMaps\\half_l.tif'

Forward slashes should work as well, in Windows, correct (I would hope, since its universal to python)? 

'P:/BsMaps/half_l.tif'
 

in the code above you have pm, not sure what that variable is meant to be in your example


Tests I got working:

# export
# I had the UI tool open
import maya.cmds as cmds 
ctx = cmds.currentCtx() # Result: artAttrColorPerVertexContext # 
cmds.artAttrPaintVertexCtx(ctx, e=True, exportfilesave='//home//users//simonan//half_l.tif', importfilemode='luminance')

Are the double forward slashes required?
 

# import file
# I had the UI tool open
import maya.cmds as cmds
ctx = cmds.currentCtx() 
cmds.artAttrPaintVertexCtx(ctx, e=True, importfileload='//home//users//simonan//half_l.tif', importfilemode='luminance')

Docs dont have an e variable in them, but the e seems to make it work.

I hope that helps


On Wednesday, 13 September 2017 07:59:20 UTC+10, Aren Voorhees wrote:
Hello all, 

I'm trying to import a blendshape attribute map from a texture file.  I expect I must be going about it the wrong way though as I can't seem to get it to work no matter how I try it.  Here is what I'm doing currently:

import maya.cmds as cmds

cmds.artAttrPaintVertexCtx('artAttrBlendShapeContext')
ctx = pm.currentCtx()
cmds.setToolTo(ctx)
cmds.artAttrPaintVertexCtx(ctx, ifl='P:\BsMaps\half_l.tif', importfilemode='luminance')

I'm getting this:

// Error:

# Traceback (most recent call last):

# File "<maya console>", line 2, in <module>

# RuntimeError: //



If anyone has done this before, or knows what I'm doing wrong, a hint would be amazing!  

Thanks

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/676ba0cb-c3cc-4c7b-b894-559086a8851e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Anderson

unread,
Sep 12, 2017, 10:23:15 PM9/12/17
to Python Programming for Autodesk Maya
Will have to give that a try when I get home. At the moment I'm on a Linux box, and just double checked, singles dont seem to play fair

Simon Anderson

unread,
Sep 13, 2017, 5:54:10 AM9/13/17
to Python Programming for Autodesk Maya
Just gave it a try on a Windows machine, it works with only the single '/' 

Aren Voorhees

unread,
Sep 13, 2017, 10:48:14 AM9/13/17
to Python Programming for Autodesk Maya
Thanks for the responses guys - I cleaned up the path to use forward slashes and I *think* that should be working fine now.  Unfortunately, I'm now having a new issue.  Here is the current code:

import maya.cmds as cmds
# As Simon mentioned, I have the paint blendShape Weights tool open before running this
ctx = cmds.currentCtx() # Returns u'artAttrBlendShapeContext'
cmds.artAttrPaintVertexCtx(ctx, e=True, ifl='P:/BsMaps/half_l.tif', importfilemode='luminance')

Now I'm getting the error:

// Error: artAttrPaintVertexCtx: Object 'artAttrBlendShapeContext' not found.

# Traceback (most recent call last):

# File "<maya console>", line 5, in <module>

# RuntimeError: artAttrPaintVertexCtx: Object 'artAttrBlendShapeContext' not found. //


How can it not be found since the ctx variable just returned it?

Aren Voorhees

unread,
Sep 13, 2017, 1:23:39 PM9/13/17
to Python Programming for Autodesk Maya
Actually, on second thought, before you spend anymore time thinking on this, I've decided to shift gears to tackle this tool - I was having a lot of problems using the artisan context stuff, so instead, I'm going to try a more "handmade" solution using the python api.  Basically at this point, I'm storing the positions of the points on a mesh, then splitting one blendshape into a right and left version.  So my new question is this (sorry to waste time on the earlier disaster!): Is there a way to mask verts using a texture so that I can move verts that have a texture value of white, while locking in place those that have a texture value of black?  Basically this would hopefully allow me to use a grayscale mask texture to mask off certain sections of a mesh (such as right and left, but probably others as well).  

I was checking out this post http://mayastation.typepad.com/maya-station/2011/03/how-to-sample-a-3d-texture.html and the sampleShadingNetwork function.  However, I can't seem to find that function in the current api docs.  Wonder if it got moved or renamed?

Todd Widup

unread,
Sep 13, 2017, 7:56:58 PM9/13/17
to python_in...@googlegroups.com
I did nearly this exact thing like 4 years ago.  same issues.
what I ended up doing was bringin my imagemap in that I wanted to use for left/right splits, using it as a textures, then quering the UV position of each point and getting the color value from the image, and storing that into a list so that it would execute faster after the initial scan of the image.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b041d046-df8f-405e-85a2-ac5420de82b0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Todd Widup
Creature TD / Technical Artist
todd....@gmail.com
Reply all
Reply to author
Forward
0 new messages