PDA

View Full Version : How to force Maya to create a reference to a non-existing file.


Ben-Davis
01-23-2013, 04:15 PM
I'm building a simple web-based asset management system. All assets are stored on a server and each client downloads an asset's working directory through a browser. When an asset is pushed back up to the server, the files within are analysed for references so that the system can track them. When analysing an asset, the system replaces any references that point to files within that asset with references that point to files on the server. When someone wants to work on an asset and therefore needs to pull it down to their machine, obviously those references need to be changed back to be relative to the local directory.

I want to handle all the processing on the server, so therefore I want to change the references in the files before they're downloaded to the client machine. The problem I'm having is that in order to change the file a reference points to, Maya insists that file already exists. Obviously the server can't see the file its trying to change the reference to, so I'm a bit stuck.

Is there a way to force Maya to change the reference path without checking if that file exists? I've thought of perhaps do a search and replace in the .ma file, but that method seems far too prone to error.

Edit: I should mention this is all python.

gmask
01-23-2013, 05:22 PM
you need to create a generic placeholder file for maya to reference

Ben-Davis
01-23-2013, 07:05 PM
The problem with that is that I can't create a file with a client-relative path because the client has a different file system, For example if the reference referenced a file on the client side with the path '/Users/User/file.ma', it's not possible to create a file with that path on a linux server.

gmask
01-23-2013, 08:08 PM
The problem with that is that I can't create a file with a client-relative path because the client has a different file system, For example if the reference referenced a file on the client side with the path '/Users/User/file.ma', it's not possible to create a file with that path on a linux server.

Off the top of my head this shouldn't be a problem if the scene file is located in the same project folder as the file that is referencing it.

Also does this system require that all the scene files be ascii? If so then you could easily manipulate the scene files without opening them in Maya.

uiron
01-24-2013, 08:37 AM
a lot more robust solution would be to fix paths before "<..>When an asset is pushed back up to the server, <..>", that is, in a client side with a tool user uses to put that back to server. Would give you much more control - checking that files are there, prompt user to fix unfixable paths (e.g., texture references in his local lib your server is not aware of), etc.

Ben-Davis
01-24-2013, 10:33 AM
Off the top of my head this shouldn't be a problem if the scene file is located in the same project folder as the file that is referencing it.

Also does this system require that all the scene files be ascii? If so then you could easily manipulate the scene files without opening them in Maya.
Yep, that works. I had no idea Maya resolves references like that. It feels a bit hacky, but it works perfectly thanks. Yeah everything is maya ascii, but manually editing the file is surely asking for problems?

a lot more robust solution would be to fix paths before "<..>When an asset is pushed back up to the server, <..>", that is, in a client side with a tool user uses to put that back to server. Would give you much more control - checking that files are there, prompt user to fix unfixable paths (e.g., texture references in his local lib your server is not aware of), etc.
I wanted to keep all the processing server-side so that everything happens in-browser. The user has a chance to check and correct everything using the web interface. Just makes for a more unified experience.

uiron
01-24-2013, 11:03 AM
I wanted to keep all the processing server-side so that everything happens in-browser. The user has a chance to check and correct everything using the web interface. Just makes for a more unified experience.

So user works in maya, saves his file, alt-tabs to browser, clicks "browse..",navigates to file, uploads it.. not really user friendly, compared to "work in maya - click upload button", as what you would normally expect in a proper pipeline.

Ben-Davis
01-24-2013, 04:13 PM
So user works in maya, saves his file, alt-tabs to browser, clicks "browse..",navigates to file, uploads it.. not really user friendly, compared to "work in maya - click upload button", as what you would normally expect in a proper pipeline.

No, the client has to run a daemon that communicates with the central server. All the user has to do is go back to browser and click the big 'check in' button, and everything is handled for them in the background. There's no browsing for files or anything like that. Doing it all in browser means that I don't have to maintain a separate maya plugin/script, which due to my schedule is really important. It also means that its application-independent; the system would work equally as well with Houdini/3DS Max as long as their exists a corresponding file handler module in the system.

uiron
01-25-2013, 04:12 AM
fair enough. I don't know how far you'll want to go with our tool, but by not having any client-side preprocessing, I feel like you're gonna hit a brick wall sooner or later.

As far as editing paths... I'd agree with gmask, just edit files directly as any text file. should not be rocket science to detect and replace them.

Ben-Davis
01-25-2013, 10:36 AM
fair enough. I don't know how far you'll want to go with our tool, but by not having any client-side preprocessing, I feel like you're gonna hit a brick wall sooner or later.

As far as editing paths... I'd agree with gmask, just edit files directly as any text file. should not be rocket science to detect and replace them.
Hmm, I suppose I hadn't thought too much about what other client-side preprocessing may need to be done in the future. Can you think of anything that would need to be done client-side that I might not have thought of?

Yeah I'm thinking that too. Using the api to change paths doesn't seem to be very reliable. I was just a little worried that editing the ma directly could start corrupting things. I'll do some tests and see how it performs. Thanks for your help guys.

uiron
01-25-2013, 12:52 PM
hm well, in the past we were dealing with spontaneous artists that would just create shaders gathering textures from all over the place of their local drives, so the idea was that the tool automatically gathers anything in "unconventional" places, fixes naming convention for textures (specular gets _SPEC suffix and diffuse _DIFF, etc), or warns about duplicates being used.
This is really just something that feels right to do on client side, so user can get immediate feedback of stuff that cannot be fixed right there, e.g. ".psd textures are not supported, convert to X before submitting files to the server".

gmask
01-25-2013, 01:15 PM
Yep, that works. I had no idea Maya resolves references like that. It feels a bit hacky, but it works perfectly thanks. Yeah everything is maya ascii, but manually editing the file is surely asking for problems?\

It's not hacky at all.. it's actually a much simpler , faster and direct way to repath all the external sources in a maya scene file without having to open it.

Ben-Davis
01-25-2013, 10:46 PM
It's not hacky at all.. it's actually a much simpler , faster and direct way to repath all the external sources in a maya scene file without having to open it.
Are you referring to editing the ascii directly? Because I'm thinking that may be the far better option. I found out today that opening a file with references that maya can't resolve will cause maya to actually delete those references.

One of the things my system does is analyse a file for references when its checked in, saving it as valid or invalid depending on the path. Obviously the problem is that when the system opens the file in maya to query the references, it deletes all of the ones it can't find, rendering the whole operation pointless. Bit stuck with this problem.

gmask
01-25-2013, 11:07 PM
Are you referring to editing the ascii directly? Because I'm thinking that may be the far better option. I found out today that opening a file with references that maya can't resolve will cause maya to actually delete those references.

One of the things my system does is analyse a file for references when its checked in, saving it as valid or invalid depending on the path. Obviously the problem is that when the system opens the file in maya to query the references, it deletes all of the ones it can't find, rendering the whole operation pointless. Bit stuck with this problem.

Yes well what I am saying is that the analysis should happen by using a script that simple reads the ascii file. Picks out the reference paths, confirms that they are valid by checking for the existence of the relevant files and then make any changes you need to make and then saving the file out again. It would never need to be opened in maya.

CGTalk Moderation
01-25-2013, 11: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.