Prod.: Engine, ver.: 6, ID: 60000597, HowTo : Images using VDF Wrapper are not embeded as in version 6

HowTo : Images using VDF Wrapper are not embeded as in version 6

Article60000597
TypeHowTo
ProductEngine
Version6
Date Added8/8/2008
Submitted byJani Forssell
Keywords

Subject

Images using VDF Wrapper are not embeded as in version 6

Summary

When I add an image to the document (using the vdImage or as vdBlock/vdInsert) then this image is a reference and not embeded in the drawing. How can I make them embeded ?

Solution

You can VERY easily solve this using these :

1) After using AddImage/cmdImage/InsertBlock/cmdInsert/CmdInsertBlockDialog (and if this returned true or a non empty object) call a fuction to cycle through all ImageDefs like :
Private Sub MakeAllEmbeded()
Dim W_ImgDef As VectorDraw_Professional.vdImageDef
Dim i As Long
For i = 0 To doc.images.Count - 1
    Set W_ImgDef = doc.images.Item(i)
    If Not (W_ImgDef.IsEmbeded) Then
        W_ImgDef.InternalSetBytes W_ImgDef.InternalGetBytes()
    End If
Next i
End Sub
And/Or

2) In the AfterAddEntity event, if the added entity is an Image then make it embeded (fires also for blocks that contain images), like :
Private Sub vDraw_AfterAddEntity(ByVal Entity As VDrawI5.vdPrimary)

'add the VectorDraw.Professional.TLB in the project's references
    If Entity.Type = "VDIMAGE" Then
        Dim img As VDrawI5.vdImage
        Dim ImgDef As VDrawI5.vdImageDef
        Dim W_ImgDef As VectorDraw_Professional.vdImageDef

        Set img = Entity
        Set ImgDef = vDraw.ActiveDocument.images.FindName(img.ImageFileName)
        Set W_ImgDef = ImgDef.WrapperObject

        If Not (W_ImgDef.IsEmbeded) Then
            W_ImgDef.InternalSetBytes W_ImgDef.InternalGetBytes()
        End If
    End If

End Sub