View Single Post
# 2 29-12-2007 , 03:40 AM
t1ck135's Avatar
Registered User
Join Date: May 2004
Location: UK
Posts: 1,991
Hi David,

I'm not too versed on the samplerInfo node but what you want spurred me on to have a look user added image
I dont know of a node that spits things out to a text file (I've not been learning Mel and Python too long) but the following below might help.

This is not the finalised requirement but will get you the pointWorld values from a generic samplerInfo node and dump them into a text file as you need.

1) Open up the Script Editor (Window -> General Editors -> Script Editor), copy this line of code in and execute it to set up a sample samplerInfo node. If you already know the name of the existing samplerInfo node you are using then you can skip this step.

Code:
shadingNode -asUtility samplerInfo -n "myNode";
2) Now we need to set up an expression that will run every frame, grab the samplerInfo pointWorld data and save it to a text file.
Open up the expression editor (Window -> Animation -> Expression Editor) and with the default settings copy the following code into the expression box:

Code:
$pWorldValues = `getAttr "myNode.pointWorld"`;
$exampleFileName = ( `internalVar -userTmpDir` + "example2.txt" );
$fileId=`fopen $exampleFileName "a"`;
fprint $fileId ($pWorldValues[0] + " " + $pWorldValues[1] + " " + $pWorldValues[2] + "\n");
fclose $fileId;
You can see that the first line is using the 'myNode' name I set up as the sample samplerInfo node. It can be changed as required.
The second line creates a temporary text file in your temp folder (mine showed as C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/) and yours *may* be in a similar place. Again the name of the file specified here can be changed.
The third line opens the specified file for appending information to.
The fourth line prints the contents to a line in the file and the fifth line closes the file.

3) Now run the movie and as it passes through each frame it will write the samplerInfo pointWorld x,y and z data to a line in the specified text file.

I dont know whether it fulfills all your needs but I hope it shows that getting information from maya into a text file can *sometimes* be quite straightforward with a bit of coding user added image

Simon

p.s, the code is just a mod of what is already in the maya help section so I cant take credit for it, even though I tested it and it works fine user added image


Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net

Last edited by t1ck135; 29-12-2007 at 03:47 AM.