PDA

View Full Version : getAttr to return full path? WTF?


AtrusDni
06-11-2007, 06:07 PM
Ok so what I want to do, and have done before, is use getAttr to return the path of a fluid cache. So I try:

string $blah = `getAttr fluid1.cacheName`;

sometimes it returns the full path: "C:\Test-Scene\Data\blah blah blah"

but sometimes it just returns the name of the cache. WHY? Does anyone know how to force it to always return the full path? This is frustrating.

scottiedoo
06-11-2007, 07:12 PM
This is just an idea and I can't really test it right now nor do I know much about fluid caches, but could it be if you have the project set to that directory or not.

To test, you could try to set your project directory to another folder or to the default and try that command again to see if it will return the full path the try setting it back to the workspace where you cache is under and see if that is it.

Again I am only speculating and offering a possible test to see if that would do it. Hopefully there is another person who knows something that I don't.

Good luck,
Scott

AtrusDni
06-11-2007, 08:07 PM
thanks for the reply scottiedoo. I have actually tried setting the project as you have mentioned with no luck.

I figured out what the problem was and a possible work around though.

By default Maya's fluid caches look in PROJECT\data folder, and the path to the fluid cache should read data\NAMEOFFLUIDCACHE, kind of like sourceimages does (sourceimages\NAMEOFFILE). Well, for some reason its losing the data\ part and just storing the name of the fluid cache. Kind of annoying, and im not sure why this is happening, but heres my work around:


// Store the Cache Path
string $cachePath = `getAttr -as ($fluidCaches[$i] + ".cacheName")`;

// Break String and Get Cache Name
string $buffer[];
tokenize $cachePath "/" $buffer;

// Check if it Returns Relative or Absolute
if(size($buffer)==1)
{
setAttr -type "string" ($fluidCaches[$i] + ".cacheName") ("data/"+$cachePath);
$cachePath = `getAttr ($fluidCaches[$i] + ".cacheName")`;
tokenize $cachePath "/" $buffer;
}

// Store Cache Name
int $count = `size($buffer)`;
string $cacheName = $buffer[($count - 1)];

// Store Original Cache Path
string $temp1 = dirname($originalScenePath);
string $temp2 = dirname($temp1);


Basically it gets the string of the cacheName, then tokenizes it based on "/" characters. If the result is 1, then that means that there is no "data/" in front of it. It then adds that to the cacheName and queries the path again, which returns the full cache path. Hope this is helpfull to anyone, and if anyone knows why its loosing the data/ part, please let me know. Thanks guys

CGTalk Moderation
06-11-2007, 08:07 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.