Automation Interface Objects

Discussion in 'AutoCAD' started by Rau Glokid, Mar 4, 2005.

  1. Rau Glokid

    Rau Glokid Guest

    The snippet of code below is from a program that I now maintain because
    programmer has left the company. The program was developed in AutoCAD 2002
    and has been 100% operational until AutoCAD 2005. After spending numerous
    hours debugging, I discovered that the statement: "Set oPViewPort = vItem"
    was causing the program to fail. The error message was "Object variable not
    set..."

    After discovering where the program was failing, I used the
    (vlax-dump-object) to snoop around. This is when I discovered the
    IAcadPViewport2 Interface Object name. I ended up getting the program to
    work by simply changing the IAcadPViewport Interface Object name to
    IAcadPViewport2

    After doing further investigation, I ended up changing the statement: If
    TypeName(vItem) = "IAcadPViewport" Then...TO: If TypeOf vItem =
    "AcadPViewport" Then... I was told that this would be a much better
    technique.

    Here's my question. When are AutoCAD Interface Objects versus AutoCAD
    Objects used? For Example, (IAcadBlockReference versus AcadBlockReference),
    (IAcadPViewport versus AcadPViewport), etc

    Here's an additional comment. I think the lesson that I have learned is that
    from a maintenance stand-point, it's not good practice to use IAcad...
    Interface Objects. Please comment.


    Original Code:
    Dim oPViewPort As AcadPViewport
    Dim vItem As Variant
    ThisDrawing.ActiveSpace = acPaperSpace ' switch to paperspace
    For Each vItem In ThisDrawing.PaperSpace ' get viewport object
    If TypeName(vItem) = "IAcadPViewport" Then
    If UCase(vItem.Layer) = "NOPLOT" Then ' use layer name to identify
    Set oPViewPort = vItem
    End If
    End If
    Next vItem
     
    Rau Glokid, Mar 4, 2005
    #1
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.