Computer Aided Design

You are not logged in. [ Login ] Why log in
(NOTE: Login is not required to post)

Batch Rotating DXF files

6/21/18       
Richard

Hello All,

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?

Thanks

Richard

6/26/18       #2: Batch Rotating DXF files ...
Gary Balcom

Richard,
Do you have any experience with Lisp routines? Someone in the know could make that work I'd bet.

Here is a link to put you down that path:
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-process-all-
drawings-in-folder/td-p/2539171

6/28/18       #3: Batch Rotating DXF files ...
Richard

Thanks Gary.

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?

Thank you

Richard

6/30/18       #4: Batch Rotating DXF files ...
david wishengrad

Message me and I will see if I can help.

7/2/18       #5: Batch Rotating DXF files ...
david wishengrad

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.
Put a copy of your dxf's in that folder.
This will import each, rotate whatever is in there and save it as a dwg in the same folder.

With some drawing that doesn't matter already open, click somewhere in the RotateDXF sub and press the F5 key.

Public Sub RotateDXF()
Dim newdoc As AcadDocument
Dim importFile As String
Dim InsertPoint(0 To 2) As Double
Dim scalefactor As Double
Dim DXF_File As String
Dim path As String
Dim SlashPos As Integer
Dim FileCountx As Integer
Dim FilesArray() As String
Dim tmpFilename As String

path = "C:\DXF\"
FilesArray = GetFiles(path)

FileCountx = -1
teststring1 = ThisDrawing.Name

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)

Else

tmpFilename = tmpFilename

End If

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

ZoomAll

newdoc.SendCommand "rotate" & vbCr & "all" & vbCr & vbCr & "0,0,0" & vbCr & "90" & vbCr

ZoomAll

DXF_File = Left$(importFile, InStrRev(importFile, ".") - 1) & ".dwg"

'newdoc.SaveAs DXF_File, acR15_dxf

newdoc.SaveAs DXF_File, acR15_dwg

newdoc.Close

Else

'do nothing

End If
Next

End Sub
Function GetFiles(ByVal FullPath As String) As String()

Dim num_files As Integer
Dim FilesArray() As String
Dim file_name As String

num_files = -1

If Right(FullPath, 1) "\" Then FullPath = FullPath & "\"
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

End If

file_name = Dir$()
Loop

GetFiles = FilesArray

End Function

7/3/18       #6: Batch Rotating DXF files ...
david wishengrad

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.

Sub Ch3_ImportingAndExporting()
' Create the circle for visual representation
Dim circleObj As AcadCircle
Dim centerPt(0 To 2) As Double
Dim radius As Double
centerPt(0) = 2: centerPt(1) = 2: centerPt(2) = 0
radius = 1
Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius)
ThisDrawing.Application.ZoomAll

' Create an empty selection set
Dim sset As AcadSelectionSet
Set sset = ThisDrawing.SelectionSets.Add("NEWSSET")

' Export the current drawing to a DXF file in the
' AutoCAD temporary file directory
Dim tempPath As String
Dim exportFile As String
Const dxfname As String = "DXFExprt"
tempPath = ThisDrawing.Application.preferences.Files.TempFilePath
exportFile = tempPath & dxfname
ThisDrawing.Export exportFile, "DXF", sset

' Delete the empty selection set
ThisDrawing.SelectionSets.Item("NEWSSET").Delete

' Open a new drawing
ThisDrawing.Application.Documents.Add "acad.dwt"

' Define the import
Dim importFile As String
Dim insertPoint(0 To 2) As Double
Dim scalefactor As Double
importFile = tempPath & dxfname & ".dxf"
insertPoint(0) = 0: insertPoint(1) = 0: insertPoint(2) = 0
scalefactor = 2#

' Import the file
ThisDrawing.Import importFile, insertPoint, scalefactor
ThisDrawing.Application.ZoomAll
End Sub

7/7/18       #7: Batch Rotating DXF files ...
david wishengrad

Any luck?

7/7/18       #8: Batch Rotating DXF files ...
Richard

Thanks David,

I have not had a chance to test this yet. I will let you know how it goes.

Thank you


Post a Response
  • Notify me of responses to this thread
  • Subscribe to email updates on this Forum
  • To receive email notification of additions to this forum thread,
    enter your name and email address, and then click the
    "Keep Me Posted" button below.

    Please Note: If you have posted a message or response,
    do not submit this request ... you are already signed up
    to receive notification!

    Your Name:
    E-Mail Address:
    Enter the correct numbers into the field below:
     

    Date of your Birth:



    Return to top of page

    Buy & Sell Exchanges | Forums | Galleries | Site Map

    FORUM GUIDELINES: Please review the guidelines below before posting at WOODWEB's Interactive Message Boards (return to top)

  • WOODWEB is a professional industrial woodworking site. Hobbyist and homeowner woodworking questions are inappropriate.
  • Messages should be kept reasonably short and on topic, relating to the focus of the forum. Responses should relate to the original question.
  • A valid email return address must be included with each message.
  • Advertising is inappropriate. The only exceptions are the Classified Ads Exchange, Machinery Exchange, Lumber Exchange, and Job Opportunities and Services Exchange. When posting listings in these areas, review the posting instructions carefully.
  • Subject lines may be edited for length and clarity.
  • "Cross posting" is not permitted. Choose the best forum for your question, and post your question at one forum only.
  • Messages requesting private responses will be removed - Forums are designed to provide information and assistance for all of our visitors. Private response requests are appropriate at WOODWEB's Exchanges and Job Opportunities and Services.
  • Messages that accuse businesses or individuals of alleged negative actions or behavior are inappropriate since WOODWEB is unable to verify or substantiate the claims.
  • Posts with the intent of soliciting answers to surveys are not appropriate. Contact WOODWEB for more information on initiating a survey.
  • Excessive forum participation by an individual upsets the balance of a healthy forum atmosphere. Individuals who excessively post responses containing marginal content will be considered repeat forum abusers.
  • Responses that initiate or support inappropriate and off-topic discussion of general politics detract from the professional woodworking focus of WOODWEB, and will be removed.
  • Participants are encouraged to use their real name when posting. Intentionally using another persons name is prohibited, and posts of this nature will be removed at WOODWEB's discretion.
  • Comments, questions, or criticisms regarding Forum policies should be directed to WOODWEB's Systems Administrator
    (return to top).

    Carefully review your message before clicking on the "Send Message" button - you will not be able to revise the message once it has been sent.

    You will be notified of responses to the message(s) you posted via email. Be sure to enter your email address correctly.

    WOODWEB's forums are a highly regarded resource for professional woodworkers. Messages and responses that are crafted in a professional and civil manner strengthen this resource. Messages that do not reflect a professional tone reduce the value of our forums.

    Messages are inappropriate when their content: is deemed libelous in nature or is based on rumor, fails to meet basic standards of decorum, contains blatant advertising or inappropriate emphasis on self promotion (return to top).

    Libel:   Posts which defame an individual or organization, or employ a tone which can be viewed as malicious in nature. Words, pictures, or cartoons which expose a person or organization to public hatred, shame, disgrace, or ridicule, or induce an ill opinion of a person or organization, are libelous.

    Improper Decorum:   Posts which are profane, inciting, disrespectful or uncivil in tone, or maliciously worded. This also includes the venting of unsubstantiated opinions. Such messages do little to illuminate a given topic, and often have the opposite effect. Constructive criticism is acceptable (return to top).

    Advertising:   The purpose of WOODWEB Forums is to provide answers, not an advertising venue. Companies participating in a Forum discussion should provide specific answers to posted questions. WOODWEB suggests that businesses include an appropriately crafted signature in order to identify their company. A well meaning post that seems to be on-topic but contains a product reference may do your business more harm than good in the Forum environment. Forum users may perceive your references to specific products as unsolicited advertising (spam) and consciously avoid your web site or services. A well-crafted signature is an appropriate way to advertise your services that will not offend potential customers. Signatures should be limited to 4-6 lines, and may contain information that identifies the type of business you're in, your URL and email address (return to top).

    Repeated Forum Abuse: Forum participants who repeatedly fail to follow WOODWEB's Forum Guidelines may encounter difficulty when attempting to post messages.

    There are often situations when the original message asks for opinions: "What is the best widget for my type of shop?". To a certain extent, the person posting the message is responsible for including specific questions within the message. An open ended question (like the one above) invites responses that may read as sales pitches. WOODWEB suggests that companies responding to such a question provide detailed and substantive replies rather than responses that read as a one-sided product promotion. It has been WOODWEB's experience that substantive responses are held in higher regard by our readers (return to top).

    The staff of WOODWEB assume no responsibility for the accuracy, content, or outcome of any posting transmitted at WOODWEB's Message Boards. Participants should undertake the use of machinery, materials and methods discussed at WOODWEB's Message Boards after considerate evaluation, and at their own risk. WOODWEB reserves the right to delete any messages it deems inappropriate. (return to top)


  • Forum Posting Help
    Your Name The name you enter in this field will be the name that appears with your post or response (return to form).
    Your Website Personal or business website links must point to the author's website. Inappropriate links will be removed without notice, and at WOODWEB's sole discretion. WOODWEB reserves the right to delete any messages with links it deems inappropriate. (return to form)
    E-Mail Address Your e-mail address will not be publicly viewable. Forum participants will be able to contact you using a contact link (included with your post) that is substituted for your actual address. You must include a valid email address in this field. (return to form)
    Subject Subject may be edited for length and clarity. Subject lines should provide an indication of the content of your post. (return to form)
    Thread Related Link and Image Guidelines Thread Related Links posted at WOODWEB's Forums and Exchanges should point to locations that provide supporting information for the topic being discussed in the current message thread. The purpose of WOODWEB Forums is to provide answers, not to serve as an advertising venue. A Thread Related Link that directs visitors to an area with inappropriate content will be removed. WOODWEB reserves the right to delete any messages with links or images it deems inappropriate. (return to form)
    Thread Related File Uploads Thread Related Files posted at WOODWEB's Forums and Exchanges should provide supporting information for the topic being discussed in the current message thread. Video Files: acceptable video formats are: .MOV .AVI .WMV .MPEG .MPG .MP4 (Image Upload Tips)   If you encounter any difficulty when uploading video files, E-mail WOODWEB for assistance. The purpose of WOODWEB Forums is to provide answers, not to serve as an advertising venue. A Thread Related File that contains inappropriate content will be removed, and uploaded files that are not directly related to the message thread will be removed. WOODWEB reserves the right to delete any messages with links, files, or images it deems inappropriate. (return to form)