How to prevent Revit from creating copy files (like myproject.0001.rvt) ?

How to prevent Revit from creating copy files (like myproject.0001.rvt) ?

Anonymous
Not applicable
12,740 Views
15 Replies
Message 1 of 16

How to prevent Revit from creating copy files (like myproject.0001.rvt) ?

Anonymous
Not applicable

Hi everyone,

 

I'm using the API to move families around. The problem is, sometime, Revit creates a copy , either of my family or of my project, names it "InitialName.0001.rvt" (then when it creates another it's 0002 and so on) and saves it in the same folder as the original. That wouldn't bother me so much if it didn't create horrendous bugs that comes from nowhere and that tells me "can't rotate this element in this position" or "can't change angle relative to the ground". When I supress those odd files it works again.

 

How do I stop those files from spawning from hell ?

If I can't, do someone knows why it creates those bug and maybe how to fix it ?

If you need any code snippet just tell me !

Thanks a lot !

12,741 Views
15 Replies
Replies (15)
Message 2 of 16

Aaron.Lu
Autodesk
Autodesk
dear JoAtt, I don't think the "can't" warnings are related with 000 files, those files are just backups of your revit file to prevent crash causing data loss.

what do you mean by "suppress those odd files"? do you mean deleting all 000 files or just avoiding using those files which have warnings?

if would be better if you can provide some sample rvt files, so that we can reproduce and detect your problem.

thanks


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 16

Anonymous
Not applicable

Dear Aaron,

 

Yes it seems odd to me too that those files could prevent my plugin from working but the fact is that when I suppress them it works again.

By supress I mean delete completely. If I could prevent their creation (both rvt files and rfa files ) that'd be better.

 

I attached some samples I use. My rvt files are a litle bit too big for the forum to accept the attachement. It says max size is 5.242mb, mines are around 5.7Mb

 

Here's what I do in my plugin,

-Load family I want to insert if not allready loaded

-Insert family on user's clic

-Least squares treatment to calculate 3 translations and 3 rotations to apply to my family to put it at the right place

-Group the family I want to move because Revit refuse to apply some rotations to it

-Apply rotations and translations to the group then ungrouping

-Check if the family is well placed and fill a family parameter named "Quality" with a grade : A,B,C or D.

-Check for interferences with other families

-Print a report with TaskDialog

 

If you need any code let me know

 

Thanks,

 

Jordi

0 Likes
Message 4 of 16

Aaron.Lu
Autodesk
Autodesk
Dear JoAtt, the process is a bit complex, to really know what's going on, you'd better create a simple code example and a simple rvt/rfa file to reproduce the problem.
BTW: I still don't think it is the 000's problem..


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 5 of 16

Anonymous
Not applicable

Dear Aaron,

 

I'll try doing that, I'll update the topic if I find anything.

 

Jordi

0 Likes
Message 6 of 16

arnostlobel
Alumni
Alumni
Hi Jordi!

This is indeed a puzzling problem. To be honest, if someone just told me this instead my reading it myself on this forum, I would not have believe it. It is because backup files (i.e. The "odd" files Revit generates) have absolutely no effect (well, should have absolutely no effect, the theory goes) on the Revit model in the main file. There is simply no connections between those files, at least not one that Revit would establish.

The number of backups created for each file can be controlled via Options of the "SaveAs" command. The minimum number of backups is one, thus one cannot really disable backing up entirely.

Every time Revit is about to save a modified file, it first asks the Windows system to create a copy of the existing (and still unmodified, untouched since a previous save) file with the next consecutive backup name (e.g. [originalname].0001.rvt, etc.) The backup file gets created in the same folder. As soon as the system successfully finishes making the backup copy, Revit then proceeds with saving changes to the main file on disk. At no time before or after this operation there is any connection between those two files, except for the detail that one is created as a copy of the other one. Thus, assuming there were no "strange" access rights set for either the main Revit file, or the folder the Revit file and its copies are contained in, I really see no possible connection.

However, I do believe, Jordi, that you really experience what you have reported. Sometimes programming is just strange. This reminds me the famous story of a car owner who reported to GM that his Chevy did not start every time after he got out of a grocery store when he bought other than a plain vanilla ice-cream. With vanilla ice-cream, the car would start, with other ice-cream kind the car would refuse. Strange, huh? Well, there was a solution, after all. Of course, it was not about the ice-cream per se; it was about the time the customer needed to buy different kinds of ice-creams. The vanilla was by the register, so the customer returned to his car quickly.

I expect this "backup files" problem is something like that. There simply must be something else. The sheer existence of backup files having any effect on how Revit works or does not work just does not make any reasonable sense. Hopefully, you will be able to provide some code and explanation what your API application actually does. (I assume the errors occur when Revit is executing an external application.)

Thank you
Arnošt Löbel
Message 7 of 16

Anonymous
Not applicable

Hi Arnost

 

It is indeed pretty odd. I still don't understand.

 

Basically what I do every morning when I arrive to work is try out my plugin, just to see if everything works the same as the last night. If it doesn't I still have an old build saved somewhere to get back to something that worked.

 

One particular morning, it would not work as the last night. I tried a thousand things over hours and when I was done trying out everything I could think of, I kind of gave up and I just went to continue writing my memoire for my degree. While browsing files I saw those backup files that I would usually delete since I'm just working on silly files just to try out the plugin. The backup files would take place so I usually supress them. When I tried the plugin later it worked again. I still didn't suspect the backup files.

 

A few days later, the same problem arised, so I checked again the new code lines I've put in the code since the last time. Couldn't find any mistakes. And when I was done checking everything and being frustrated as ever I once again saw those backup files and deleted them. But this time I suspected them and tried the plugin one more time. And it worked. I tried a thousand times again, it never failed.

 

When I had this problem again, and backup files existed, simply renaming my rvt file with another name would fix the problem.

 

I understand that it can't be that but that's how it looks. And I simply haven't had a problem since I'm very carefull about deleting them or renaming my file. Right now I've put this in the "Known issues" of my user manual. Until I find out what's going on, this will do I guess.

 

Jordi

0 Likes
Message 8 of 16

pteague
Advocate
Advocate
This is one of those "out there" type of questions, but since this seems to be an "out there" type of problem, I figured I'd ask it.

Is there anywhere in your code where you are opening or looking into a RVT file and something in your code might be getting truncated or otherwise mixed up and trying to perform the operations on a RVT file other than the one you are currently accessing?

Its a pretty ethereal questions, but never hurts.
0 Likes
Message 9 of 16

Anonymous
Not applicable

Hi pteague,

 

The only thing I open or look into is a family file.

I check wether or not if the family is already loaded in the rvt file, if not I import it then place it, if it is I simply place it.

 

My plugin is supposed to be launched inside a project. So once it is launched, I mess with any rvt file.

 

Is it possible that, even if the name of 2 rfa files are different, those two rfa bare the same name in Revit, and that if I check if it is allready loaded it finds that it is while in reality it is not ?

 

Don't know if I'm really clear about this.

 

Jordi

0 Likes
Message 10 of 16

pteague
Advocate
Advocate

@Anonymous wrote:

Is it possible that, even if the name of 2 rfa files are different, those two rfa bare the same name in Revit, and that if I check if it is allready loaded it finds that it is while in reality it is not ?


That's what I'm wondering.  I don't know the answer, but someone else who knows more about it (Arnost, Jeremy) might have some insight.  Just trying to ask questions that may lead to more information.

0 Likes
Message 11 of 16

arnostlobel
Alumni
Alumni

@Anonymous wrote:

Is it possible that, even if the name of 2 rfa files are different, those two rfa bare the same name in Revit, and that if I check if it is already loaded it finds that it is while in reality it is not ?


I am not sure I understand this question? By the "2 RFA files" you do not mean the Revit backup files anymore, correct? Just checking.

I believe that if you have two family files of different file-name even though they are copies of the same original RFA file, you can load them both into a project without Revit complaining that one already exist. Does that answer the question.

 

I want to ask something too:

Jordi, you mentioned that "my plugin is supposed to be launched inside a project". Is it a document macro, then?

 

Another question that has not been ask yet, and probably does not have to be, but I'll ask anyway: I suppose you have a lot of space on the disk were the original and the backup files are stored, right?

Arnošt Löbel
0 Likes
Message 12 of 16

Anonymous
Not applicable

I was thinking about a backup file. I was just wondering if the families of a file and it's backup files are identified under the same name. And hence, if I tried to import an updated version of a family, it would not, and I would not be aware of that.

 

I don't know what is a document macro. Here's how I do it :

 

UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;


if (null == uidoc)
{
message = "Lancez cette commande dans un document ouvert.";
TaskDialog.Show("Erreur", message);
return Result.Failed;
}

 

And yes I do have plenty of space on my disk.

 

Jordi

0 Likes
Message 13 of 16

yurchenco_igor
Explorer
Explorer

it is possible to set special directory for that backup files to save in? it would be a good option if is not possible yet.

Message 14 of 16

Seychellian
Advocate
Advocate

This x10

0 Likes
Message 15 of 16

Ar.KripaPanjari
Observer
Observer

Would deleting those backup files (which are as heavy as the original file) do any harm? Can I just delete them as I tend to get confused?

0 Likes
Message 16 of 16

jeremy_tammik
Alumni
Alumni

No harm whatsoever. You just lose the backup.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes