.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Converting DXF to Dwg 2004 using .net

6 REPLIES 6
Reply
Message 1 of 7
ArkRost
1427 Views, 6 Replies

Converting DXF to Dwg 2004 using .net

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?

6 REPLIES 6
Message 2 of 7
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 7
ArkRost
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. 

Message 4 of 7
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 7
arcticad
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))
Message 6 of 7
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 7
arcticad
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))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost