See the top rated post in this thread. Click here

Results 1 to 4 of 4

Thread: Export to earlier version

  1. #1
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Export to earlier version

    I'm currently using Civil3d 2011, will move to 2012 as soon as it's released. I have some users that are resisting the change to Civi3d, still using Land Desktop Companion. Until I can get management support to upgrade them, I'm trying to write a function to automatically save a copy of the current dwg, with a new name, to the previous version. (file version 2007). any ideas how to do that?

    I've got an event, for Begin documentclose, but my question is with this line:


    acdoc.database.saveas(newDwgName,true,dwgversion.(not sure what goes here),acdoc.database.securityparameters)

    i have 2 questions. what do i set the dwg version to, and how do i tell it to
    automatically overwrite the existing file?

  2. #2
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Question Re: Export to earlier version

    now i'm having a different problem. This is the code i have so far:


    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Microsoft.Win32

    Public Class ExportVersion

    <CommandMethod("AddDocEvent2")> _
    Public Sub AddDocEvent2()
    'define variables
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument


    'add event handler
    AddHandler acDoc.BeginDocumentClose, AddressOf ExportVersion
    End Sub
    Public Sub ExportVersion(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentBeginCloseEventArgs)
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
    Dim strDwgName As String = acDoc.Name
    Dim newDwgName As String = ".\XREF_BASE.dwg"
    Dim obj As Object = Application.GetSystemVariable("DBMOD")
    Dim temp As Type = Autodesk.AutoCAD.in
    MsgBox(strDwgName)
    MsgBox(DwgVersion.Current)
    acDoc.Database.SaveAs(newDwgName, True, DwgVersion.AC2To22, acDoc.Database.SecurityParameters)
    If Not (System.Convert.ToInt16(obj) = 0) Then
    If MsgBox("Do you want to save this drawing?", MsgBoxStyle.YesNo, "Save Drawing") = MsgBoxResult.Yes Then
    acDoc.Database.SaveAs(acDoc.Name, True, DwgVersion.Current, acDoc.Database.SecurityParameters)
    End If
    Else
    acDoc.CloseAndDiscard()
    End If
    End Sub
    End Class

    what's happening, is the code is running at file load, so i'm getting the messageboxes, and then the code never ends, so i cant do anything else, and have to endtask acad.exe to get it to stop.

    here's my overall plan:
    if a drawing is called "xxxxx_WORKING.dwg" (in file version 2010) then when the document is closed,
    automatically export it to file version 2007, called XREF_BASE_xxxxx.dwg. 9the x's will be the same
    so i need to check the filename and find out if it says working, that's not hard.
    if it does, then i'm having issues with the saving down, as i said earlier.
    plus, i'm going to need it to overwrite the XREF_BASE_xxxxx.dwg file every time the full file is closed. not sure how to go about this.

    also, even when i get the above code to run, it's not actually closing the document.
    and it'll need to overwrite

  3. #3
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Re: Export to earlier version

    A whole lot of trial and error seems to have done the trick.
    I'll post my code up here, after I finish the file name checks, and cleanup my debug messages and so forth.

  4. #4
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    1

    Default Re: Export to earlier version

    Okay, i've got it mostly working.
    the only issue is, when Civil3d first opens, with 'Drawing1' and you click open and open a new dwg, it changes the current dwg name immediately, so when 'Drawing1' is closing, it's already detected the new drawing name, so it's making a copy before it really should be.
    if you manually close Drawing1, so no dwgs are open, and then open your file, it will work.
    I've attached the dll file, and the class module used for it.

    Feel free to modify it to suit your needs.

    Feel free to ask questions/make comments to
    amaser@mcbrideengineering.com
    Attached Files Attached Files

Similar Threads

  1. Saving to an earlier version
    By Wish List System in forum ACA Wish List
    Replies: 7
    Last Post: 2015-05-09, 03:48 PM
  2. Saving to earlier version, STB to CTB
    By dwescott in forum CAD Standards
    Replies: 5
    Last Post: 2010-02-20, 12:06 AM
  3. Saving to an earlier version problem
    By tsigler in forum ACA General
    Replies: 1
    Last Post: 2009-01-29, 05:22 PM
  4. Batch export to an earlier version of CAD
    By .chad in forum AutoCAD Customization
    Replies: 4
    Last Post: 2007-06-12, 07:10 PM
  5. save to earlier version
    By iffans in forum Revit Architecture - General
    Replies: 5
    Last Post: 2005-04-08, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •