• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual Basic Customization

    Reply
    Active Member
    Posts: 8
    Registered: ‎01-23-2013
    Accepted Solution

    VBA - Convert 2010 Acad Drawings to 2004/LT2004

    285 Views, 5 Replies
    02-01-2013 05:49 AM

    Hey all,

     

    I have a simple and quick question:

    Is is possitlbe using VBA (not .NET) to open an Acad 2010 Drawing, then re-save it as a Acad 2004/LT2004 Drawing?

     

    I need to be able to import the drawing into some third party software, and for some reason, it is incompatible with the newer versions.

     

    I would also like to know if it is possible to convert ANY version of a drawings (be it 2007, 2000, 2012, etc...).  Also if at all possible, is there an easy way to re-save a drawing that was created using other software (aka SolidWorks) to use AutoCAD's specific file formatting?  I know that when you try to open a drawing created in SolidWorks (opening in AutoCAD), that it will display a message saying the drawing was created by an external application.  I would like to be able to change the file so that AutoCAD created the drawing.

     

     

    Thanks for all your help, it is greatly appreciated! :smileyhappy:

    God Bless,

    -Nick

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎01-23-2013

    Re: VBA - Convert 2010 Acad Drawings to 2004/LT2004

    02-05-2013 07:39 AM in reply to: Millerni456

    Okay so after doing some research I came across the following forums.  It looks like I might be able to accomplish this using LISP, but this would still need to be done using VBA (as I need to interface with Microsoft Office).

     

    Here's the forum about running LISP using VBA:

    http://forums.autodesk.com/t5/Visual-Basic-Customization/Run-lisp-command-in-autocad-from-VBA/td-p/2...

     

    Here's the forum about saving as a specified file format.

    http://forums.augi.com/showthread.php?50250-Use-Saveas-Command-from-a-Lisp-Routine

     

    So, as I try to understand this even further;  if anyone can answer, I'd like to know if taking this route is possible.

     

    Can I run a VBA program to open AutoCAD, and then execute a LISP file to save the drawing as a different format?

    Please use plain text.
    *Expert Elite*
    Posts: 706
    Registered: ‎04-27-2009

    Re: VBA - Convert 2010 Acad Drawings to 2004/LT2004

    02-06-2013 06:52 AM in reply to: Millerni456

    If you just want to convert drawing format from Acad2010 to Acad2000/4/7, you can use Dwg TrueView to do batch job.

     

    If you have to do it with VBA code, you can easily save them as older drawing format all the way back to R14 version (assume you use Acad2010-2012). You certainly do not need to mix your VBA code with LISP code (e.g. you do it either with LISP or VBA, both are simple enough.

     

    You do like this (pseudo code, assuming you have a string array of dwg file names):

     

    Dim fileNames As String()

    Dim saveAsFielNames As strinig()

     

    ''Then fill the strinig arrays with dwg file names

     

    Dim dwg As AcadDocument

    Dim app As AcadApplication

    Set app=ThisDrawing.Application

     

    Dim i As Integer

    For i=0 to Ubound(fileNames)

        Set dwg=app.Documents.Open(fileNames(i))

        ''Do something if needed

        dwg.SaveAs saveAsFileName(i), ac2000(4/7))_dwg

        dwg.Close

    Next

     

     

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎01-23-2013

    Re: VBA - Convert 2010 Acad Drawings to 2004/LT2004

    02-06-2013 10:32 AM in reply to: norman.yuan

    Thanks for the reply!

     

    It looks like this will work!

    However, is it possible you can enumerate all the different dwg file formats?

     

    Please use plain text.
    *Expert Elite*
    Posts: 706
    Registered: ‎04-27-2009

    Re: VBA - Convert 2010 Acad Drawings to 2004/LT2004

    02-06-2013 12:19 PM in reply to: Millerni456

    If you open VBA IDE in autoCAd and open Object Browser, find AcSaveAsType in the left and highlight it, you can see all the enum values of it for your versio of AutoCAD.

     

    Attached is the screen picture froom my acad2012.Untitled.png

     

     

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎01-23-2013

    Re: VBA - Convert 2010 Acad Drawings to 2004/LT2004

    02-07-2013 07:25 AM in reply to: norman.yuan

    Wow thanks, that will be very helpful!

     

    Again, I appreciate all your efforts!

     

    God Bless,

    -Nick

    Please use plain text.