View Full Version : file import and file lock problem

01 January 2008, 08:12 PM
Hi guys/gals,

I've created a batch script in maya (python) that grabs the contents of a directory and for each file found (.3ds in this case) it imports the file, changes the rotation to the one used by maya, freezes the transformations and deletes the history, quadrangulates everything if it is triangulated and then saves it out to a maya file.

All goes fine and it does its job, its just that once completed all the .3ds files in the original folder are locked and cant be deleted without shutting down maya and restarting it. I'm on Windows XP if that helps.

I've had a look into file referencing and if for some reason this is affecting it but I dont think it is. I'm also fairly new to the node structure of maya so dont know if it keeps something cached or linked to the file, even if you start a new scene?

Any help or pointers would be much appreciated.

01 January 2008, 10:44 PM
How exactly are you importing the objects. Are you creating references or actually importing them?

01 January 2008, 11:17 PM

I think I'm doing a straight import but all the multitude of options in the file command might be the confusing issue.
Here's the block of code running the import, rename and save section. It's in a loop but that shouldnt matter here.
I read the help quite a few times and tried various elements seeing if references were in use but couldnt figure it out. The first line was without the reference attributes but still didnt work. I'm guessing that playing about with it for too long has dulled my senses somewhat ;)

mc.file(startDir+i, i=True, type=fileType, preserveReferences=True, loadReferenceDepth='none')
mc.file(startDir+i, rename=endDir+i+'.mb')
mc.file(save=True, force=True, type='mayaBinary')

EDIT: I just opened one of the .3ds files that was being used for the import and the model has been rotated as if it were in maya so it may well be referencing the object instead of importing it... any tips on the correct import commands would be very useful


01 January 2008, 10:47 PM
Here's a version of the script I was playing with, very hacky in some places as I'm still learning all the commands and ways to do things.
I'm probably missing something fairly obvious but here it is anyway:


01 January 2008, 07:58 AM
hmmm sorry i'm not too good with python. I don't see any reason that it should be holding on to the files though.

01 January 2008, 11:00 AM
cheers for having a look though, much appreciated :)

I might try converting the commands to mel and running the same to see if it is some kind of strange happening. I cant imagine that making a difference but its worth trying.
Just for reference I'm running Win XP 64bit in case there is some strange 64bit bug that is hidden to the world ;)


01 January 2008, 08:40 PM
Not sure if this will be of help, but here are some things to try to perhaps narrow the issue down:

1. If its not necessary, remove the -preserveReferences option. This will be dependent on your setup if indeed your 3ds importer is importing references (I suspect it isn't) and if your scenes have references. That'd be about the only thing I could imagine that might have this effect in your script.

2. Try unloading the 3ds import plugin at the end of the script. See if that releases the locks. Just a quick check to see who's to blame.

01 January 2008, 10:20 PM
Hi Keilun,

I think I've tried knocking off that attribute but then again I tried lots in various stages to see if there was one causing the problem and may have muddled it up with the others.
Good idea about knocking off the 3ds import plugin - I'll give that a go tomorrow and see if it helps. It'd be nice to be able to disable and enable it in the script but I dont know if thats possible from the command line?


01 January 2008, 05:05 PM
I tried removing preserveReferences as well as the load/unload option for the plugin and it still has the file locked. I also tried using Mel to to make sure the bindings weren't dodgy.

There's nothing to say that this machine hasnt gone a bit funny so until I can test it on another one it'll have to wait.
Cheers for the pointers guys


01 January 2008, 10:54 AM
this means it is a maya bug .
locks while importing progress and forgets unlocking.
SOLVE "unlocker"
2. download the small utility in first link from google result.
3. happy unlocking

this fixes any other bugs of softwares and OSes.

01 January 2008, 11:22 PM
cheers for the heads up on that little program butCherHeLL, I'll give that a go tomorrow :)


CGTalk Moderation
01 January 2008, 11:22 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.