how to translate "getinterfaceobject"

Discussion in 'AutoCAD' started by perry, Jun 24, 2004.

  1. perry

    perry Guest

    I have the following vba code donated by Mike Tuersley for calling dll
    procedures from vba but I want to translate
    it to Vlisp and am having problems (a little rusty in Lisp). And yes, the
    dll is registered.
    heres the original vba stuff:

    Sub DLLExample()
    'declare object thru which we access our dll
    Dim VB6DLL As Object
    'capture the dll by using the DLL Name "." Class Module Name that holds
    the
    'function/sub you're going to call
    'NOTE This DLL needs to be in the AutoCAD support path - DO NOT REFERENCE
    IT
    'TO THIS PROJECT!!!!!!!!!!!!!!
    Set VB6DLL =
    ThisDrawing.Application.GetInterfaceObject("DLLExample.Class1")
    'run whatever public sub is available from our DLL's class module
    'in this case it is RunMe
    'NOTE: VB6DLL will wait and wait while the dll is in use then it will
    'come back to the next line here:
    VB6DLL.RunMe
    'clean up before leaving
    Set VB6DLL = Nothing
    End Sub

    Now heres what I did in Vlisp:

    (vl-load-com)
    (defun c:test( / interface)
    (setq interface (vla-getinterfaceobject "DLLExample.Class1")) ; error:
    bad argument type: VLA-OBJECT "DLLExample.Class1"
    (vlax-invoke-method interface "RunMe")
    (setq interface nil)
    )

    any pointers would be appreciated, Thanks
     
    perry, Jun 24, 2004
    #1
  2. The first argument to (vla-getinterfaceobject) should be the AcadApplication
    object.

    --
    R. Robert Bell


    I have the following vba code donated by Mike Tuersley for calling dll
    procedures from vba but I want to translate
    it to Vlisp and am having problems (a little rusty in Lisp). And yes, the
    dll is registered.
    heres the original vba stuff:

    Sub DLLExample()
    'declare object thru which we access our dll
    Dim VB6DLL As Object
    'capture the dll by using the DLL Name "." Class Module Name that holds
    the
    'function/sub you're going to call
    'NOTE This DLL needs to be in the AutoCAD support path - DO NOT REFERENCE
    IT
    'TO THIS PROJECT!!!!!!!!!!!!!!
    Set VB6DLL =
    ThisDrawing.Application.GetInterfaceObject("DLLExample.Class1")
    'run whatever public sub is available from our DLL's class module
    'in this case it is RunMe
    'NOTE: VB6DLL will wait and wait while the dll is in use then it will
    'come back to the next line here:
    VB6DLL.RunMe
    'clean up before leaving
    Set VB6DLL = Nothing
    End Sub

    Now heres what I did in Vlisp:

    (vl-load-com)
    (defun c:test( / interface)
    (setq interface (vla-getinterfaceobject "DLLExample.Class1")) ; error:
    bad argument type: VLA-OBJECT "DLLExample.Class1"
    (vlax-invoke-method interface "RunMe")
    (setq interface nil)
    )

    any pointers would be appreciated, Thanks
     
    R. Robert Bell, Jun 24, 2004
    #2
  3. perry

    Jeff Mishler Guest

    Perry, compare what you did in VBA with the lisp line......look hard at the
    Application........the error was saying it needs the vla- object that the
    method applies to.....

    HTH,
    Jeff
     
    Jeff Mishler, Jun 24, 2004
    #3
  4. perry

    perry Guest

    Sheesh, you guys are gonna make me work(think) eh? what good are ya? ;)
    had to break out the 'ole activex programmers manual...
    THIS seems to work

    (defun c:test( / interface)
    (setq interface (vla-getinterfaceobject (vlax-Get-Acad-Object)
    "DLLExample.Class1"))
    (vlax-invoke-method interface "RunMe")
    (setq interface nil)
    )
     
    perry, Jun 24, 2004
    #4
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.