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

DXF File to a specified AutoCad Version

1 REPLY 1
Reply
Message 1 of 2
herrwolf1
365 Views, 1 Reply

DXF File to a specified AutoCad Version

Hello,
I am trying to iterate through a directory and save all the existing DXF files to version 2004. Everything works well until I try to "SaveAs". I've included the entire routine here. If anyone could help, I would greatly appreciate it.

Thank You,

Eric.

________________________________________________________________________________

Imports Autodesk.AutoCAD
Imports System.IO

Private Sub ResetDXFFilesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetDXFFilesToolStripMenuItem.Click
Dim strJobNum As String = Nothing

If TextBoxJobNumber.Text = "" Then
strJobNum = InputBox("Please Type A Job Number", "Job Number?", "00000")
Else
strJobNum = TextBoxJobNumber.Text
End If

' Find Directory
Dim strDir As String = Nothing
strDir = "J:\" & strJobNum & "\DXF"

If Directory.Exists(strDir) Then
Dim AcadApp As AcadApplication

AcadApp = CreateObject("Autocad.Application")

' Show AutoCad or Not
AcadApp.Visible = False

Dim acadDoc As AcadDocument
acadDoc = AcadApp.ActiveDocument

Dim CollDoc As AcadDocuments
CollDoc = AcadApp.Documents

Dim NewCurrentDirectory As DirectoryInfo = New DirectoryInfo(strDir)
If NewCurrentDirectory.Exists Then

Dim fileArray As FileInfo() = NewCurrentDirectory.GetFiles
For Each oFile In fileArray
If oFile.Extension = ".dxf" Then
CollDoc.Open(oFile.FullName)
acadDoc = AcadApp.ActiveDocument
acadDoc.ActiveSpace = Interop.Common.AcActiveSpace.acModelSpace

' Here Is the Problem
'acadDoc.SaveAs(oFile.FullName,?????????

acadDoc.Close()
End If
Next
End If
Else
MessageBox.Show("Job Number: " & strJobNum & " doesn't exist." & vbCr & "I'm exiting without doing anything", "Invalid Job Number", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End If

End Sub
1 REPLY 1
Message 2 of 2
_gile
in reply to: herrwolf1

Hi,

While you're using the COM interop, have a look at AutoCAD developer's help > ActiveX and VBA Reference > Methods > SaveAs method


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

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