60000475 Save a file as VDI version 4.1

Article 60000475
Type HowTo
Product Engine
Version 6
Date Added 4/14/2008 12:00:00 AM
Fixed (4/14/2008 12:00:00 AM)
Submitted by Igor Gegusin

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

Send comments on this topic.