Hi
I have noticed that a file is xrefed much faster if the file has been opened at some point. (Wtih the file I tested with it was 45 sec vs 1,5 sec) This must mean that the file is cached and can very quickly opened later if it has been opened.
I have an application that xref other files as overlay xref's. This is very slow since the xrefed files haven't been opened. And it will be this slow every time i xref them since they are never opened. Is there a way I can cache the files manually or something like that?
Hello Fredrik,
Sorry, I could not reproduce this behavior. Can you please let me if there is anything different from what I have been trying ?
Trial 1 :
Started AutoCAD 2013
Attached a large drawing as an overlay xref and timed it at 25 seconds.
Closed AutoCAD
Trial 2:
Started AutoCAD 2013
Opened the large drawing
Created a new drawing and attached the large drawing as an overlay xref and timed it. It was roughly the same (~ 25 seconds)
Please let me know the exact steps to reproduce this behavior.
Hi
Are you sure the large drawing has never been opened on your machine before?
What I did, Step1:
I received a drawing from a coworker. Attached drawing as an overlay xref, timed it to 45 seconds. Closed AutoCAD
Step 2:
Opened the drawing. Closed AutoCAD
Step 3:
Opened empty file and attached drawing as overlay xref. Timed it to 1,5 seconds.
I think I found out why. AutoCAD generates "cached" files of some sort in C:\users\<user>\AppData\Local\Temp. Maybe that is why it can open it so fast if it has opened it before.
This affects my program that xrefs files. A scenario is that the drawings that are going to be xrefed are on a network location, and will only be xrefed by the users of my program.
Maybe this is normal Windows / HDD cache?
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi again, I coworker of mine found this:
"
File format
New file format "AutoCAD 2013 Drawing" is used.
AutoCAD 2013 introduces a new file format that includes changes to the thumbnail preview file format, as well as new controls for graphics caching.
Thumbnail previews in the new AutoCAD 2013 DWG file format are now stored as PNG images, providing higher-quality thumbnail previews in a smaller file size. Image resolution is still controlled by the THUMBSIZE system variable. However, the maximum valid value has increased from 2 to 8. If you do not wish to include thumbnail previews in the drawing you can still use the RASTERPREVIEW system variable (or the new THUMBSAVE) to disable them. Note that only 3D drawings make use of a larger thumbnail. The UPDDATETHUMBSNOW and UPDATETHUMBNAIL system variables are no longer needed and have been removed from AutoCAD 2013.
When you save a drawing containing 3D Solids in the new AutoCAD 2013 file format, a graphics cache file is automatically stored in a folder named “GraphicsCache” under your user app data folder. Two new system variables, CACHEMAXTOTALSIZE and CACHEMAXFILES, enable you manage the cache files."
"
I am not sure how to use this information about the system variables. The simple thing i was thinking was to write a function that opens all dwg-files and closes them to read them to cache. Is this the best way?
I am having som trouble doing this. In the code under the document I open does not seem to be put as active document and if I set it as active document my function stops.
public static void OpenAllFiles(string[] files) { foreach (string file in files) { bool opened = OpenFile(file); bool closed = CloseFile(); } } public static bool CloseFile() { DocumentCollection acDocMgr = AcadApp.DocumentManager; try { acDocMgr.MdiActiveDocument.CloseAndDiscard(); return true; } catch (Autodesk.AutoCAD.Runtime.Exception ex) { return false; } } public static bool OpenFile(string strFileName) { DocumentCollection acDocMgr = AcadApp.DocumentManager; if ((File.Exists(strFileName))) { Document newDoc = acDocMgr.Open(strFileName, false); return true; } else { return false; } }
Hi Fredrik,
Sorry for the delay.
Have you tried setting the "CACHEMAXFILES" to 0 ? This will ensure that AutoCAD does not perform the caching of the files. The behavior will then be like that of AutoCAD 2012 when we did not have such caching of drawings.
Regarding your query on opening all the drawings and ensuring that they get cached, it is possible but I am not sure if that is the best way. I will enquire with the engineering team and will let you know if there is a better way to do that.
Here is a sample code to open a set of drawings and close them without saving. The drawings seem to be getting cached.
[CommandMethod("Test", CommandFlags.Session)] public void TestMethod() { string[] files = { "C:\\Temp\\1.dwg", "C:\\Temp\\2.dwg" }; try { foreach (String file in files) { if (!File.Exists(file)) continue; Document doc = Application.DocumentManager.Open(file); doc.CloseAndDiscard(); } } catch (System.Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.Message); } }
Hi
Thanks for the answer.
Have you tried setting the "CACHEMAXFILES" to 0 ? This will ensure that AutoCAD does not perform the caching of the files. The behavior will then be like that of AutoCAD 2012 when we did not have such caching of drawings.
I do not want to set "CACHEMAXFILES" to 0. I want the files to be cached. This ensures that my application can xref the files very fast.
I will use the code you posted unless a better solution appears.
Hi again
Your code for openening and closing all files works allmost fine. The program stops if I run your function right after opening AutoCAD.
The reason seems to be that when you open an existing drawing when you've just opened AutoCAD the unsaved "Drawing1.dwg" that always shows up when opening AutoCAD is closed. So when I close the first drawing I opened no drawings are open anymore and the function stops.
It seems to work fine if you have done something with "Drawing1.dwg" or opened another drawing first since it will not be closed when opening a new drawing.
Any ideas to handle this situation?
In case you weren't aware, the graphics cache is only of the solids data. No other entity types have their graphics cached in the cache file.
Thanks Art. Some of the drawings that I originally used while trying to reproduce the increase in Xref time did not have solids in them, which now explains why the results that I saw werent consistent.
Fredrik,
How about using the accoreconsole.exe to have the drawings cached ?
1) Create a simple script file with "(princ "Done")"
The script file does not perform any actual task.
2) Run AccoreConsole.exe and provide the drawing path and the script file path
accoreconsole.exe /i "C:\Temp\Torus.dwg" /s "C:\Temp\Test.scr" /l en-US
I did find a new file getting created under "%appdata%\Autodesk\AutoCAD 2013 - English\R19.0\enu\GraphicsCache"