How To Detach an raster image in vba

Discussion in 'AutoCAD' started by shake, Jul 12, 2004.

  1. shake

    shake Guest

    i want to detach the images in autocad throught VBA . please suggest on this
     
    shake, Jul 12, 2004
    #1
  2. shake

    Luis Alberto Guest

    Hello shake!

    Time ago someone sent me this code, it works great for me (on Autodesk Map,
    but I think it will also work in AutoCAD).

    ----Begin CODE----
    Sub DeleteImage(ByVal sName As String)
    'This sub will erase the image named "sName" from the drawing an also will
    dettach it.
    On Error GoTo NoSuchRaster
    ' Get the Image Dictionary.
    Dim oImageDictionary As AcadDictionary
    Set oImageDictionary = ThisDrawing.Dictionaries("ACAD_IMAGE_DICT")

    ' Get the raster definition
    Dim oImageDef As AcadObject
    Set oImageDef = oImageDictionary(sName)

    ' Erase the image's definition
    oImageDef.Delete

    NoSuchRaster:
    'If there is any error, the raster does not exist.

    ' Destroy created objects
    Set oImageDictionary = Nothing
    Set oImageDef = Nothing
    End Sub
    ----End CODE----

    Hope this helps.

    Bye!

    this
     
    Luis Alberto, Jul 13, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.