.NET

Reply
Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 1 of 4 (161 Views)

Import PageSetups

161 Views, 3 Replies
04-19-2012 01:54 PM

Hello everybody,

 

I am trying to import a page setup into the active drawing; the code works fine but I get an error when trying to save the file: Error writing/closing file. I've attached the code, can someone help me? I need to run the code in batch mode. I've tried different ways of saving but I get the same error.

 

Thanks,

 

e.g.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 2 of 4 (158 Views)

Re: Import PageSetups

04-19-2012 02:03 PM in reply to: e.g.

Hi,

 

I haven't tried anything of your code, but wondering about these things (I would avoid):

  • Why do you lock the document twice (in ActiveDrawingImportPageSetups and in CopyPageSetup)
  • What is the TransAction tr in ActiveDrawingImportPageSetups for? You do your transaction-handling in the subroutine already and I don't see any reason for this one (and so for nested transactions).
  • Why do you use COM-object-handling (through PropertyDefinitions of Interop.AcadDocument) for saving, why don't you just use the db.SaveAs version?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 3 of 4 (153 Views)

Re: Import PageSetups

04-19-2012 02:29 PM in reply to: Alfred.NESWADBA

Hi Alfred,

 

thanks for your quick answer; I had the extra transaction because I had different pagesetups, for model and paper and some layouts were not initialized so I had to make them active and then import the pagesetup. Anyway, I've updated and attached the sample code; it gives me the same error. My feeling is that I am missing something when using the source database.

 

Thanks for helping.

 

e.g.

Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 4 of 4 (145 Views)

Re: Import PageSetups

04-19-2012 02:51 PM in reply to: e.g.

Ok, I've made a shorter version of the code, and I don't know why I cannot save the file. I've tried to also run the command in application context.

 

Thanks for any suggestion.

 

e.g.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.