Product : Converter, Version : 4.1.6.1028, ArticleID : 41023362

HowTo : Delete xref block.

Article41023362
TypeHowTo
ProductConverter
Version4.1.6.1028
Date Added1/5/2004
Submitted byTakis
Keywords

Subject

Delete xref block.

Summary

When you attach an xref,

    vd.CommandAction.CmdXref("A", "X:\vdrawsamples\xref\pd-23.vdi") 
the vdpro adds a block definition with the xrefpath set to X:\vdrawsamples\xref\pd-23.vdi and an insert entity with the blockname set to pd-23 to the drawing.

When you export the files,

    x = vd.ActiveDocument.ExportDistributionFiles(fldname, fext, Vd4x3, longflag) 
the vdpro changes the block and the xrefpath is set to pd-23.vdi

When you detach the xref,

    x = vd.CommandAction.CmdXref("D", "X:\vdrawsamples\xref\pd-23.vdi") 
the vdpro changes the block's xrefflag to 0

Since the insert stays in the file, you can not purge the (xref)block. Because of this, I can not insert the exported file unless I rename it.

Is there a way to get rid of the block and insert, short of cycling through the blocks and entities and manually deleteing them?

Solution

Option Explicit

Private Sub Command1_Click()
Dim filename As String
  
    filename = App.Path + "\pd-23-income.vdi"
    vd.CommandAction.CmdXref "A", filename
    vd.CommandAction.Zoom "E", "USER", "USER"
    MsgBox "The file is attached"
  
    vd.ActiveDocument.ExportDistributionFiles App.Path, ".dwg", Vd4x3, 0
    MsgBox "The files were exported"
   
    Dim blk As vdBlock
    Dim blkname As String
    
    filename = App.Path + "\pd-23-income.vdi"
    Set blk = vd.ActiveDocument.Blocks.FindName("pd-23-income") 'without pathname and without extension
    If Not blk Is Nothing And blk.XrefFlag = 1 Then
        blk.Erase
    End If
    vd.ActiveDocument.SaveAs App.Path + "\test.vdi", Vd4x3
End Sub