Hi guys!
I'm newish to python in maya, and new to this discussion group. Thanks for
reading my topic!
Ok so I have a unique issue, tested in Maya 2013.0 x64.
Issue is I have a python script, reassigning texture paths and when the
script is run on an opened file that changes are made to the path of the
texture AND the file scene is saved, AND the path is visibly there...
When the script is run, that fileTextureName node WILL NOT ACCEPT a setAttr
var and remains UNMODIFIED.
However, if you reopen that saved file in a fresh maya session, the script
works perfectly.
Following is some example code:
* import maya.cmds as cmds*
*files = cmds.ls(type="file")*
* project_path = "/wherever"*
* *
* def myCopy (path, newpath):*
* copy2(path, newpath)*
* #example of doin somethin to path.. can be commented out as
the return i get in my function prints back below*
* dosomethingtothepath = newpath.remove('\\','\')*
* return **dosomethingtothepath*
*for item in files: *
* fullpath = cmds.getAttr('%s.fileTextureName' %item)*
* newpath = myCopy(fullpath, project_path) #mycopy uses copy2 and
returns the new path*
* print "Copied: " + fullpath + " to: " + newpath #newpath
echos back correctly here from mycopy function!!!*
* cmds.setAttr("%s.**fileTextureName**" %item, newpath,type="string")
#setting the new path*
* print cmds.getAttr('%s.fileTextureName' % (item) #echos back
old file path!!!!!!!*
*
*
*
*
So to recreate the scenario:
1. create simple maya scene with primitive and shader with texture. Save
scene.
2. edit the project path var so it goes somewhere on your system. run this
script.
3. should work correctly first time. so change the texture to some other
file in shader, then save. run script... see? attribute not changed as
visible in listener.
4. close maya. reopen. reopen modifed saved scene. run script. it works.
One other note is that the final path i am assigning in newpath DOES NOT
EXIST locally, though I am not sure this makes a difference.
Thanks for taking time to read about my troubles.
- Aleks
*
*
*
*
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/1df4ad7a-057e-4146-807a-4404d085bf41%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.