VBA vs. DLL question

Discussion in 'AutoCAD' started by Maksim Sestic, Sep 4, 2004.

  1. Dear all,

    Anybody has an answer to the following question: does procedure written in DLL perform faster/slower than it's AutoCAD VBA counterpart?

    I'm using standard calls to AutoCAD's functions in both environments. I also use DLL-based classes (containing properties, methods and enums) for procedures in both VBA and VLisp. Is there any special "catch" to be aware of?

    Another question is how to implement event-based procedure that's stored in DLL library? Any tip/code sample is welcome.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Sep 4, 2004
    #1
  2. Maksim Sestic

    manoj_vest Guest

    Anybody has an answer to the following question: does procedure written in DLL perform faster/slower than it's AutoCAD VBA counterpart?

    It depends the way you are using your DLL. The dll cannot be used standalon, so either you need to create and exe and from that exe call the methods and properties in the classes of dll or create a vba project and from VBA call the dlls methods and properties. If you are using from within vba or you can create an arx project and frm arx too you can call the dll. In these two cases i.e. vba or arx, the performance of dll is same as a native vab procedure. But if you are using your dll from another exe which is out of process the dll will be slower because it is not running in the same process of AutoCAd.

    I'm using standard calls to AutoCAD's functions in both environments. I also use DLL-based classes (containing properties, methods and enums) for procedures in both VBA and VLisp. Is there any special "catch" to be aware of?

    I have not used the same with the lisp bwcoz I don't have expertise in lisp, but there is nothingt to worry about call from VBA. The only care you need to take that on an event you should not do a taks which will fire the same event, which will lead to a circular even and your application may hang. E.g. on NewDrawing you should not create a new drawing (AcadDocuments.add).

    Another question is how to implement event-based procedure that's stored in DLL library? Any tip/code sample is welcome

    I am not too much clear about your question but I am trying to explain, Create a vba project. Add reference to your dll in the vba project by clicking Tools>>References and selection your dll. The corresponding to your event create the object of your class in your dll and call the methods.

    Hope I am able to explain your queries.

    Regards
    Manoj
     
    manoj_vest, Sep 6, 2004
    #2
  3. Maksim Sestic

    manoj_vest Guest

    Anybody has an answer to the following question: does procedure written in DLL perform faster/slower than it's AutoCAD VBA counterpart?

    It depends the way you are using your DLL. The dll cannot be used standalon, so either you need to create and exe and from that exe call the methods and properties in the classes of dll or create a vba project and from VBA call the dlls methods and properties. If you are using from within vba or you can create an arx project and frm arx too you can call the dll. In these two cases i.e. vba or arx, the performance of dll is same as a native vab procedure. But if you are using your dll from another exe which is out of process the dll will be slower because it is not running in the same process of AutoCAd.

    I'm using standard calls to AutoCAD's functions in both environments. I also use DLL-based classes (containing properties, methods and enums) for procedures in both VBA and VLisp. Is there any special "catch" to be aware of?

    I have not used the same with the lisp bwcoz I don't have expertise in lisp, but there is nothingt to worry about call from VBA. The only care you need to take that on an event you should not do a taks which will fire the same event, which will lead to a circular even and your application may hang. E.g. on NewDrawing you should not create a new drawing (AcadDocuments.add).

    Another question is how to implement event-based procedure that's stored in DLL library? Any tip/code sample is welcome

    I am not too much clear about your question but I am trying to explain, Create a vba project. Add reference to your dll in the vba project by clicking Tools>>References and selection your dll. The corresponding to your event create the object of your class in your dll and call the methods.

    Hope I am able to explain your queries.

    Regards
    Manoj
     
    manoj_vest, Sep 6, 2004
    #3
  4. Maksim Sestic

    Matthew Guest

    You could potentially change things that would fire the reactor again. You
    would need to wait for the reactor to get done doing it's thing. Then when
    the reactor was done, turn it off, then do the things that would cause it to
    fire. Then turn it back on again. Technically manoj_vest, is right though
    you can't make the reactor fire from within itself.
    This is a concept I have used in lisp I don't know if it can be done in VBA
    or VB?

    Just my 2 cents
    Matthew


    DLL perform faster/slower than it's AutoCAD VBA counterpart?
    standalone, so either you need to create and exe and from that exe call the
    methods and properties in the classes of dll or create a vba project and
    from VBA call the dlls methods and properties. If you are using from within
    vba or you can create an arx project and frm arx too you can call the dll.
    In these two cases i.e. vba or arx, the performance of dll is same as a
    native vab procedure. But if you are using your dll from another exe which
    is out of process the dll will be slower because it is not running in the
    same process of AutoCAd.
    also use DLL-based classes (containing properties, methods and enums) for
    procedures in both VBA and VLisp. Is there any special "catch" to be aware
    of?
    lisp, but there is nothingt to worry about call from VBA. The only care you
    need to take that on an event you should not do a taks which will fire the
    same event, which will lead to a circular even and your application may
    hang. E.g. on NewDrawing you should not create a new drawing
    (AcadDocuments.add).
    in DLL library? Any tip/code sample is welcome
    Create a vba project. Add reference to your dll in the vba project by
    clicking Tools>>References and selection your dll. The corresponding to your
    event create the object of your class in your dll and call the methods.
     
    Matthew, Sep 7, 2004
    #4
  5. Mat,

    Firing event-based procedures (aka reactors) from VBA is relatively
    straightforward job. My question was the way to establish similar event
    scheme via DLL that's somehow referenced in ACAD, either via VLisp or VBA.
    Other problem is how to establish persistent reactors otherwise than through
    VLisp (which is not possible via VBA as far as I know).

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Sep 8, 2004
    #5
  6. Maksim Sestic

    Matthew Guest

    I have a persistent vba reactor. from somebody here I think. It fires the
    right command for editing text based on a double pick on an object. the code
    goes in the thisdrawing part of the DVB file and is automatically loaded
    into every drawing.

    ??
    you mean like that?
    Matthew
     
    Matthew, Sep 9, 2004
    #6
  7. Mat,

    What you are referring to is "transient reactor" (per Autodesk specs), which
    means - it works as soon as you load your application and establish
    event-based procedures. On the other hand, "persistent reactors" work
    always, i.e. even if there is no user application loaded. There's nice book
    on ACAD internal structures written by Dietmar Rudolph.

    Regards,
    Maksim Sestic
     
    Maksim Sestic, Sep 9, 2004
    #7
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.