1

I have written an application to open and print a dwg file. The plotting process is working correctly; however, when I looked at the Plot and Publish Details window, I saw that the File property is set to <UnSaved Drawing> instead of my dwg file name.

I mean something like this :

Sheet :UnsavedDwg_2-Model - Plotted

File : <UnSaved Drawing>> 
Category name :> 
Page setup :> 
Device name : \\server\MyPrinterName> 
Plot file path :> 
Paper size : Letter

what is my mistake?!!!

Note : I have used the Open method of DocumentCollection class to open my dwg file and this code to plotting the opened dwg file to printer.

My code to open dwg file :

String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;
Document doc = null;

if(File.Exists(MyDWGFilePath))
{
   doc = dm.Open(MyDWGFilePath, false);
   Application.DocumentManager.MdiActiveDocument = doc;
}
M_Mogharrabi
  • 1,369
  • 5
  • 29
  • 57
  • Your tagging says you're using C#, but in your description you say you are using LISP? Can you provide code of what you are doing? As a first guess though, if you make any changes to the drawing after opening and before printing that could be the reason for the name issue. – Origin Jan 01 '12 at 04:51
  • @Origin,I do apologize for my mistake. I have edited my post and appended my opening code too. – M_Mogharrabi Jan 01 '12 at 05:01
  • Does it do the same thing when the file you are printing is local? – Origin Jan 01 '12 at 05:11
  • I have test it but now i receive 2 errors with any file paths.the first one in command line (Cannot create temporary plot stamp log file. plot not logged.) and the other as a message (INTERNAL ERROR : !dbplotset.cpp@440 : elockviolation !!!! ) – M_Mogharrabi Jan 01 '12 at 05:47
  • 1
    Where is it trying to create the plot log file? Also - when you open the document you may need to specify a mode other than read-only. That's usually what causes me to get an eLockViolation – Origin Jan 01 '12 at 06:00
  • I do not know.I have disabled Automatically save plot and publish log and also Create log file option.I have set the second parameter of open method to false and it means that my dwg file should open in write mode. – M_Mogharrabi Jan 01 '12 at 06:39
  • Thanks for your immediate reply,I have solved my problem by using a lisp command (_PLOT) instead of the code i have used for plotting and now it works successfully, but when i wanted to use my code in main application i have received this error : Method 'CopyTo' in type 'Autodesk.AutoCAD.ApplicationServices.DocumentCollection' from assembly 'Acmgd, Version=18.2.0.0, Culture=neutral, PublicKeyToken=null' does not have implementation. – M_Mogharrabi Jan 01 '12 at 08:35
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6286/discussion-between-m-mogharrabi-and-origin) – M_Mogharrabi Jan 01 '12 at 10:26

1 Answers1

0

Your open code basically opens the existing drawing and loads the contents of it it into a new document instance. Since the new document instance did not exist before, it has no save name and hence your plot message shows the unexpected filename.

I'm not 100% sure if this will work (I don't have my autoCAD machine in front of me to test), but you can try changing your loading code to:

String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;

if(File.Exists(MyDWGFilePath))
{
  dm.Open(MyDWGFilePath, false);
}
JayP
  • 809
  • 7
  • 9
  • Thanks for your reply, but i have tried this later and i found that it has a problem.it opens the dwg file but not as active document.so i have to do something like my code to activate the dwg file. – M_Mogharrabi Jan 01 '12 at 05:44
  • So does that mean it's resolved? If you load it via `Open` and then make it active with the DocumentManager, does the print log display how you expect? – Origin Jan 01 '12 at 05:45
  • No, my problem exactly is what you said.I mean i have set my dwg file as active document but when the plot code is completing the file name is instead of my dwg file path. – M_Mogharrabi Jan 01 '12 at 06:40