|Home » Forums » CAD » Message||Login|
You are not logged in. Consider these WOODWEB Member advantages:
Batch Rotating DXF files6/21
Does anyone know if there's a way that I can automate the process of opening a number of DXF files, rotating them 90° and re saving them?
Here is a link to put you down that path:
I had a look at the link you posted. Does look like Lisp would be the way to go. However I have zero experience with this & looks like it would be beyond me at this time and unfortunately I don't have the time to spend on learning this right now.
Do you know of anyone who maybe willing to assist with this? Or where I could look for someone?
Message me and I will see if I can help.
If you have not installed the ACAD vba enabler, do it.
Then open the VBA IDE and in the acad project window, choose "thisdrawing" and add the code below.
Make a folder on your C: drive called dxf.
With some drawing that doesn't matter already open, click somewhere in the RotateDXF sub and press the F5 key.
Public Sub RotateDXF()
path = "C:\DXF\"
FileCountx = -1
For FileCountx = LBound(FilesArray) To UBound(FilesArray)
importFile = LCase(path & FilesArray(FileCountx))
tmpFilename = importFile
Inpos = InStrRev(tmpFilename, ".")
If Inpos > 0 Then
tmpFilename = Mid(tmpFilename, Inpos + 1)
tmpFilename = tmpFilename
If tmpFilename = LCase("dxf") Then
Set newdoc = Application.Documents.Add("acad.dwt")
InsertPoint(0) = 0#
InsertPoint(1) = 0#
InsertPoint(2) = 0#
scalefactor = 1#
newdoc.Import importFile, InsertPoint, scalefactor
newdoc.SendCommand "rotate" & vbCr & "all" & vbCr & vbCr & "0,0,0" & vbCr & "90" & vbCr
DXF_File = Left$(importFile, InStrRev(importFile, ".") - 1) & ".dwg"
'newdoc.SaveAs DXF_File, acR15_dxf
newdoc.SaveAs DXF_File, acR15_dwg
Dim num_files As Integer
num_files = -1
If Right(FullPath, 1) "\" Then FullPath = FullPath & "\"
file_name = Dir(FullPath, vbNormal)
Do While Len(file_name) > 0
If FileName "." And FileName ".." Then
num_files = num_files + 1
ReDim Preserve FilesArray(0 To num_files)
FilesArray(num_files) = file_name
file_name = Dir$()
GetFiles = FilesArray
If they need to be saved as a dxf, then it must be exported. ACAD does not open dxf's or save them directly. They must be imported and exported. My code above uses the important method, but does not export. This sample code below provides an example of how to use export.
' Create an empty selection set
' Export the current drawing to a DXF file in the
' Delete the empty selection set
' Open a new drawing
' Define the import
' Import the file
I have not had a chance to test this yet. I will let you know how it goes.