passing params to an activex object...

Discussion in 'AutoCAD' started by James Maeding, Feb 11, 2005.

  1. Hi there,
    I created a activex dll that has one class.
    I created properties for the class with my let and get statements.

    My problem is I cannot seem to set properties from lisp when the property is a variant or an object.
    Is the vlax-put-property statement appropriate to use for items that normally are passed in "byref" in VB?

    I would expect there to be a vlax-set-property because in VB, you have to use the Set statement when passing in an
    object to another objects properties, like this...
    Set objLDTManip.LDTApp = objLDTApp

    where objLDTManip is the object and LDTApp is the property whose type is AeccApplication
    I will kill myself if lisp does not have the ability to pass objects and arrays into other activex objects...


    More info...
    I can create the LDTManip object defined by my LDTUtil dll in lisp with:

    (setq APP (vlax-get-acad-object))
    (setq LDTMANIP (vla-GetInterfaceObject APP "LDTUtil.LDTManip"))

    and it works fine.

    I can set basic string properties with:

    (vlax-put-property LDTMANIP "HAlgName" HA-NAME)
    (vlax-put-property LDTMANIP "VAlgName" VA-NAME)

    But I am getting type mismatch errors when trying to pass in arrays or objects to the LDTManip object with these
    statements:

    first the Civil Design Application object

    (SETQ AECCAPP (VL-CATCH-ALL-APPLY 'VLA-GETINTERFACEOBJECT (LIST (VLAX-GET-ACAD-OBJECT) AECCAPPID ))))
    (vlax-put-property LDTMANIP "LDTApp" AECCAPP) <-- does not work


    then the variant array created from list of PVI's

    ;MAKE PVI'S SAFEARRAY
    (SETQ PVIARRAY (vlax-make-safearray vlax-vbdouble '(0 . 2) (cons 0 (- (length NEWPVIS) 1))))
    (SETQ INDEX 0)
    ;NOTE THAT vlax-safearray-fill DOES NOT WORK FOR THIS STEP DUE TO THE INDEX ORDER OF THE ARRAY
    (FOREACH PVI NEWPVIS
    (vlax-safearray-put-element PVIARRAY 0 INDEX (NTH 0 PVI))
    (vlax-safearray-put-element PVIARRAY 1 INDEX (NTH 1 PVI))
    (vlax-safearray-put-element PVIARRAY 2 INDEX (NTH 2 PVI))
    (SETQ INDEX (+ 1 INDEX))
    )
    (SETQ VAR-PVIARRAY (vlax-make-variant PVIARRAY))

    (vlax-put-property LDTMANIP "NewPVIs" VAR-PVIARRAY) <-- does not work

    In my VB class code, the LDTApp prop is declared as:
    Private mobjLDTApp As AeccApplication

    and NewPVIs is:
    Private mvarNewPVIs() As Variant

    Any ideas why the object will accept simple strings but not the more complicated object types?
    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Feb 11, 2005
    #1
  2. Well I think I lied.
    I did an object dump on the LDTManip variable in lisp and did not get my properties and methods.
    So I have a bigger problem to deal with, my object is not functional yet.

    I am not sure whats up, I made an activex dll project in VB6, put all my code in a class module, and compiled it.
    Compiling it registers the dll, so there must be something I have to do to expose that class'es properties and methods.

    Anything obvious I should check? (besides my pulse...)
    thanks
    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Feb 12, 2005
    #2
  3. James Maeding

    ECCAD Guest

    James,
    Just curious. Why you doing it that way, when there is
    an excellent VBAIDE inside AutoCAD ?
    Just have your VB6 'include' the AutoCAD vba *.ocx/*.dll
    and use call to 'sub' .....
    Bob
     
    ECCAD, Feb 12, 2005
    #3
  4. Bob,
    What you are saying is why use lisp when VBA should do?
    The answer is VBA does not come close to the power of Lisp with ObjectDCL.
    I could go on and on, but VB/VBA lacks certain things that make lisp so slick, grdraw, grread, easy command line access,
    lists and so on. You may not have thought about it, but lists are way easier than arrays in VB. You can nest and
    renest as much as desired. In VB, you cannot redim a multidimensional array except for the last param.
    VB has nice structure to it and API access, lots of good stuff no doubt.

    I would have thought you would ask "why not just manipulate LDT from lisp?", that is the real question.
    The answer is that the LDT API has bugs! It randomly crashes when adding PVI's to a FG vertical alignment.
    Adesk knows this is a bug, and I have tried desperately to avoid making the dll like I am.
    I am all ears for better solutions, but going to VB or VBA for my main program is not an option. I coded the same prog
    in VB a long time ago and hated the results. Way too many sendcommands...it was rediculous, and not because I didnt
    know how to use the object model, it was things like the grdraw that were not available in the activex object model.

    So I am going down the dll road, which actually opens up huge doors.
    If vb/vba had a few things improved, I would consider switching.
    thanks for replying though.

    ECCAD <>
    |>James,
    |>Just curious. Why you doing it that way, when there is
    |>an excellent VBAIDE inside AutoCAD ?
    |>Just have your VB6 'include' the AutoCAD vba *.ocx/*.dll
    |>and use call to 'sub' .....
    |>Bob

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Feb 12, 2005
    #4
  5. ok, looks like the object dump is seeing my object, here is what I get:

    ; _LDTManip: nil
    ; Property values:
    ; Algns (RO) = nil
    ; HAlgName (RO) = ...Indexed contents not shown...
    ; LDTApp (RO) = ...Indexed contents not shown...
    ; NewPVIs (RO) = ...Indexed contents not shown...
    ; PVIs (RO) = nil
    ; ReturnMsg (RO) = ""
    ; VAlgName (RO) = ...Indexed contents not shown...
    ; Methods supported:
    ; GetAligns ()
    ; GetPVIs ()
    ; PutPVIs ()

    Are those (RO)'s = "Read Only"
    that would be bad as they are supposed to be public properties...
    Any ideas what is up...

    Here is my class code for the props and let/get/set staements.
    things like the HAlgName prop should not be read only, I did the let statements....

    Option Explicit

    'this prop to recieve incoming LDT root object
    Private mobjLDTApp As AeccApplication
    'this for specifying what horiz algn to use
    Private mstrHAlgName As String
    'this for specifying what vert algn to use
    Private mstrVAlgName As String
    'this for containing array of avalable alignment names
    Private mvarAlgns() As Variant
    'this for holding current alignment name
    Private strCurHAlgn As String
    'this for holding new pvi's
    Private mvarNewPVIs() As Variant
    'this for holding found pvi's
    Private mvarPVIs() As Variant
    'return message
    Private mstrReturnMsg As String


    Public Property Set LDTApp(ByRef objLDTApp As AeccApplication)
    Set mobjLDTApp = objLDTApp
    End Property

    Property Let HAlgName(strHAlgName As String)
    mstrHAlgName = strHAlgName
    End Property

    Property Let VAlgName(strVAlgName As String)
    mstrVAlgName = strVAlgName
    End Property

    Property Get Algns() As Variant
    Algns = mvarAlgns
    End Property

    Property Let NewPVIs(ByRef varNewPVIs As Variant)
    mvarNewPVIs = varNewPVIs
    End Property

    Property Get PVIs() As Variant
    PVIs = mvarPVIs
    End Property

    Property Get ReturnMsg() As String
    ReturnMsg = mstrReturnMsg
    End Property
    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Feb 12, 2005
    #5
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.