.NET

Reply
New Member
ArkRost
Posts: 2
Registered: ‎04-07-2012
Message 1 of 7 (572 Views)

Converting DXF to Dwg 2004 using .net

572 Views, 6 Replies
04-07-2012 12:33 PM

Hi everyone!

 

I'm using AutoCAD 2012 version 18.2. I need to programmatically open .dxf file, change font and save as .dwg version AC1800. I do it with the folowing code http://pastie.org/3745519. The problem is that after saving as AC1800 and open the result file, Autocad says that some errors occured and offer to recover file. After this it works fine. If I save as DwgVersion.Current or DwgVersion.Newest it works fine.

 

Does anyone have ideas what I'm doing wrong?

*Expert Elite*
Alfred.NESWADBA
Posts: 9,572
Registered: ‎06-29-2007
Message 2 of 7 (570 Views)

Re: Converting DXF to Dwg 2004 using .net

04-07-2012 12:44 PM in reply to: ArkRost

Hi,

 

please paste code here and not on any other server (as of security, I don't love it to go to some servers I don't now and so don't trust).

 

Have you tried to open the dxf manually and save it in 2004-format?

Where does the DXF come from, what software (and version) wrote these files?

Have you tried to create a new file, save it as DXF and try your code then?

 

If you have some proxy-objects (or you are running something like ACA, MEP, Civi3D, ....) then saving back to 2004 may result in defect DWG's anyway.

 

Upload one of these DXF's, that may help. Also give us the info of how you get these code-lines startet (did you create a command that is executed by hand or by script or how is this code called?). The reason why I ask this is your estimation that after using the DocumentManager.Open function makes this document current so you can get it then with MdiActiveDocument ... may be but must not be.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
New Member
ArkRost
Posts: 2
Registered: ‎04-07-2012
Message 3 of 7 (540 Views)

Re: Converting DXF to Dwg 2004 using .net

04-08-2012 10:36 PM in reply to: Alfred.NESWADBA

Thanks for your reply. Sorry for not answering for two days. Got problems with my Internet connection.

 

It works fine when I open it manually and save it in 2004 format. Unfortunatelly I have no idea where these drawings come from. I'm attaching the sample DXF to this post.

 

In addition, I've noticed that it saves fine in Current or Newest version so it seems that the opened document indeed becomes MdiActiveDocument.  I've tested saving in 2007 and 2010 formats. It works fine, too. Also it would be nice if you can provide the information about differences between DwgVersion.Current and DwgVersion.Newest. 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,572
Registered: ‎06-29-2007
Message 4 of 7 (513 Views)

Re: Converting DXF to Dwg 2004 using .net

04-09-2012 07:43 AM in reply to: ArkRost

Hi,

 

before I try anything with coding:

Have you tried _AUDIT after opening the DXF and before saving it to 2004? AutoCAD 2013 gives one error that has to be repaired. Try it first and let me know if that was already what you where looking for?

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 5 of 7 (511 Views)

Re: Converting DXF to Dwg 2004 using .net

04-09-2012 08:00 AM in reply to: Alfred.NESWADBA

Files that are saved back to 2004 will fail to open properly because of the "Genuine AutoCad check" it does. So it may ask you to repair the file to open it. if the file is resaved as 2010 file in code then it won't have this issue.

---------------------------



(defun botsbuildbots() (botsbuildbots))
*Expert Elite*
Alfred.NESWADBA
Posts: 9,572
Registered: ‎06-29-2007
Message 6 of 7 (508 Views)

Re: Converting DXF to Dwg 2004 using .net

04-09-2012 08:07 AM in reply to: arcticad

Hi,

 

>> Files that are saved back to 2004 will fail to open properly because of the "Genuine AutoCad check"

So why does that only occur when saving by application and it does not occur when doing a manual SAVEAS?

 

Back in my brain (very very far away) there are some red lamps telling me "there was something with 2004 and programatic save" but it doesn't come to front of my remembering ;(

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 7 of 7 (504 Views)

Re: Converting DXF to Dwg 2004 using .net

04-09-2012 08:37 AM in reply to: Alfred.NESWADBA

I don't have any special insite as to why.

My Assumtion is that the object types that are contained in the drawing are still 2010 objects and they have been put in a 2004 wrapper. Where the Save As actually converts each item into a 2004 type object.

 

I know in MEP / Architecture there is a specific Export To function for turning all of the objects into 2004 objects.

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.