Prod.: Engine, ver.: 6, ID: 60000475, HowTo : Save a file as VDI version 4.1

HowTo : Save a file as VDI version 4.1

Article60000475
TypeHowTo
ProductEngine
Version6
Date Added4/14/2008
Submitted byIgor Gegusin
Keywords

Subject

Save a file as VDI version 4.1

Summary

I would like to save a drawing as vdi-file of version 4.1.6.1030 (year 2004) for the purpose of backward compatibility.

Solution

This can be done with the help of the vdfOpen.ocx. In an empty project add a form with a Version 6.x Wrapper (named Vdraw1) a button and a vdfOpen control (vdfopen.ocx named VDFOpen1) and add this code to the button click event handler :
Private Sub Command1_Click()
Dim success As Boolean
Dim filename As String
    ' Vdraw1 is a VDF 6.x Wrapper component
    ' You should add to your project the VDFOpen control (vdfopen.ocx) that comes with version 6.x
    
    filename = App.Path & "\\test.vdi"
    VDraw1.ActiveDocument.Entities.AddLine Array(0, 0), Array(1, 1)
    success = VDraw1.ActiveDocument.SaveAs(filename) ' this file is saved as VDI 5.1
    
    ' The SaveToMemory & CreateFromMemory will not work as the Vdraw1 makes a version 6.x "MemoryFile" while
    ' the CreateFromMemory of VDFOpen1 needs a version 5.x "MemoryFile"
    
    VDFOpen1.ActiveDocument.CreateFromMemory
    success = VDFOpen1.ActiveDocument.Open(filename) ' open the VDI 5.1
    If success Then
        success = VDFOpen1.ActiveDocument.SaveAs(filename, Vd4x1) ' Save this again as VDI 4.1
        If success Then MsgBox ("Saved as VDI version 4")
    End If
End Sub