Mel script to create a file node and open file browser in one click. Error.

Mel script to create a file node and open file browser in one click. Error.

Anonymous
Not applicable
2,323 Views
5 Replies
Message 1 of 6

Mel script to create a file node and open file browser in one click. Error.

Anonymous
Not applicable

I am not a scripter but I am trying to create a simple mel script to make a file texture node and launch the file browser in one go....I have this but it does not work:

 

//create file node

shadingNode -asTexture -isColorManaged file;
$file = `ls -sl`;

 

//turn off filtering
setAttr ($file[0] + ".filterType") 0;

 

//try to open file browser
select $file;
AEfileTextureBrowser ("AEassignTextureCB " + $file[0] + ".fileTextureName")image;

 

I have tried several variations of the last line but I always get the following error:

"Wrong number of arguments on call to AEfileTextureBrowser"

 

Why?

Is something like this possible?

I just want a way to click one "file" button and have a file dialog open right away like other 3d apps.

 

Thanks

0 Likes
Accepted solutions (1)
2,324 Views
5 Replies
Replies (5)
Message 2 of 6

damaggio
Mentor
Mentor

You know an easy way is just save a preset under the file node preset and  it loads your favorite image, you can save a bunch, you can do the same with 2d placement node or your favorite HDR image for IBL...give it a try.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks and that is an interesting tip but I'm really just trying to have a script that adds a file texture node and then launches the file browser so I can browse to a file rather than have a specific file pre-loaded. Compared to other 3d applications that I use every day in my work I find maya to need far more clicks to do basic things like, in this case, add a file. I'm trying to fix some of these time-sinks with scripts while also learning some basic mel in the process.

 

If anyone knows how I might adjust my simple script above so that it works to launch the file browser I'd love to hear it. Thanks...

0 Likes
Message 4 of 6

Anonymous
Not applicable
Accepted solution

I got it working...

 

//create file node

shadingNode -asTexture -isColorManaged file;

$file = `ls -sl`;

 

//turn off filtering

setAttr ($file[0] + ".filterType") 0;

 

//open file browser

select $file;

AEfileTextureBrowser ("AEassignTextureCB " + $file[0] + ".fileTextureName") $file[0] image;

 

That will make a one-click file add!

Message 5 of 6

Anonymous
Not applicable
Thank`s a lot man!!!!!!!!!! I have had the same problem in the same line, command and ...you`ve helped me! lol
0 Likes
Message 6 of 6

toby.gainesQTXCX
Contributor
Contributor

John...

I found this thread while looking for a way to reduce the constant repetitive clicks in Maya 😄 

So not only do these bastards force us to fix their crap for them, they also forced us to get personal AD accounts to stay employed. I'm guessing that diapers and pee bottles aren't so far away 

0 Likes