Simulate Attribute Editor Button Press (or workaround)

479 views
Skip to first unread message

Andres Weber

unread,
Aug 1, 2016, 10:47:54 AM8/1/16
to Python Programming for Autodesk Maya
Hey guys,

Tough one to search on the list since I'm not sure of the right way to put it...but I was trying to setup a button that would toggle shaders to "Generate Preview" for UDIM textures.  I wasn't able to finalize exactly what the command is that the button is running since echo all commands returned this:

import maya.app.general.fileTexturePathResolver

maya.app.general.fileTexturePathResolver.findAllFilesForPattern(


So I wrote something around it:




import pymel.core as pm
import re
import maya.app.general.fileTexturePathResolver
   
udim_re
= '(1[0-9]{3})'

for filenode in [file for file in pm.ls(type='file') if file.uvTilingMode.get() == 3]:
    filepath
= filenode.fileTextureName.get()
    tokenized_path
= ''
   
for tile in re.findall(udim_re, filepath):
        tokenized_path
= filepath.replace(tile, '<UDIM>')
   
    files
= maya.app.general.fileTexturePathResolver.findAllFilesForPattern(tokenized_path, None)
    maya
.app.general.fileTexturePathResolver.computeUVForFiles(files, tokenized_path)

But then I realized this doesn't actually update the viewport at all.  If anyone has any pointers I'm all ears.  Also if anyone has advice for this situation...when you are looking to find the code executed by a button but can't quite find the applicable code...where to turn or the best way to google-fu it with the proper search term.

33th...@gmail.com

unread,
Aug 2, 2016, 9:38:02 PM8/2/16
to Python Programming for Autodesk Maya
you can view that file

C:\Program Files\Autodesk\Maya2016\Python\Lib\site-packages\maya\app\general\fileTexturePathResolver.py

33th...@gmail.com

unread,
Aug 2, 2016, 9:39:14 PM8/2/16
to Python Programming for Autodesk Maya, 33th...@gmail.com
On Tuesday, August 2, 2016 at 6:38:02 PM UTC-7, 33th...@gmail.com wrote:
> you can view that file
>
> C:\Program Files\Autodesk\Maya2016\Python\Lib\site-packages\maya\app\general\fileTexturePathResolver.py

sorry, I spoke too soon. nm me :)

Andres Weber

unread,
Aug 3, 2016, 11:23:17 AM8/3/16
to Python Programming for Autodesk Maya, 33th...@gmail.com
Haha I always forget about .__file__ when I'm working on Maya things...
Turns out glancing through that code isn't super helpful, at least from my cursory checkout since it doesn't have any code that updates the viewport and just contains the two functions I'm using.  Thanks for the reminder about actually opening the code I'm using though, really interesting regexes in there!
Reply all
Reply to author
Forward
0 new messages