USIGN THE GETPOINT IN A DLL VB PROGRAM

Discussion in 'AutoCAD' started by Tomas, May 8, 2004.

  1. Tomas

    Tomas Guest

    How can I use the getpoint function in a dll VB program, the problem is that
    when I use it, the Cursor disappears in AutoCAD, only appears when it´s over
    a toolbar menu, but, again disappears when I reach the drawing area.

    I need Help, Thank you

    Tomas
     
    Tomas, May 8, 2004
    #1
  2. Are you hidding the form first ?
     
    Jorge Jimenez, May 8, 2004
    #2
  3. Tomas

    Tomas Guest

    hello

    Yes, I am hiding the form, but it doesn't work


    Saludos

    Tomas

    Venezuela
     
    Tomas, May 8, 2004
    #3
  4. Try using a modeless form

    myform.show vbModeless

    then

    dim pto as variant
    me.hide
    pto = miApp.Activedocument.Utility.Getpoint(,"Pick a point")
     
    Jorge Jimenez, May 8, 2004
    #4
  5. Is your VB DLL an ActiveX server?

    If so, how does the method that shows the form
    get called? Is it from LISP, VBA or something
    else?
     
    Tony Tanzillo, May 8, 2004
    #5
  6. Tomas

    Tim Badger Guest

    Tomas, I'll assume you have created an activex dll...What you need to do is
    launch your vb class function or sub from vba. This will allow to get the
    pick box to show and still use a modal dialog. If you need an example,
    email me.

    Tim Badger
     
    Tim Badger, May 9, 2004
    #6
  7. Tomas

    Tomas Guest

    Hello Tony:

    Thank you for your email, it is called from a VB Form Button, which is
    embedded in a ActiveX DLL class, which is called from Lisp.

    I have written a VB ActiveX.DLL, which has one CLASS and one Form, I use the
    Class to be called from Lisp, and the class has a method to show the VB
    form, which makes some special Structural Engineering calculations, and it
    has a button that I use to pick a point in AutoCAD to make the insertion of
    a drawing, every thing it´s ok, I hide the form, the AutoCAD appears but the
    AutoCAD cursor disappears when I Reach the drawing area. The only way to
    recover it´s using CTRL ALT DEL and kill AutoCAD.

    What's wrong.

    Tomas
     
    Tomas, May 9, 2004
    #7
  8. Because of how VB forms work, control is not returned
    to AutoCAD until the _initial_ call to the form's Show()
    method returns. That does not happen until your form calls
    Hide() without a subsequent call to Show().

    In order to get this to work, you need to call your
    VB dll using VBA. You can start the VBA macro from
    LISP, and then have it call the method that leads
    to the call to the form's Show() method.
     
    Tony Tanzillo, May 9, 2004
    #8
  9. Tomas, there should be no problem calling the VB Active X DLL from LISP.
    There is NO need to call VBA for this.

    Something like this should work:

    (vl-load-com)
    (setq acd (vlax-get-acad-object))
    (setq mysrv (vlax-create-object "MYDLL.myclass"))
    (vlax-invoke mysrv "myMethod" acd)


    inside myclass there should be a sub like this:

    Private Sub myMethod (acadapp as autocad.acadapplication)
    set myapp = acadapp
    myForm.show
    end sub

    inside a Global module (global.bas for example)
    Public myapp as autocad.acadapplication

    to get a point using a button in your VB myForm :

    Private Sub Command1_Click()
    dim pto as variant
    on error resume next
    me.hide
    pto = myapp.activedocument.Utility.GetPoint(, "Pick a point:")
    if err then
    'getpoint was canceled
    else
    debug.print "X:";pto(0)
    debug.print "Y:";pto(1)
    debug.print "Z:";pto(2)
    end if
    me.show

    End Sub
     
    Jorge Jimenez, May 10, 2004
    #9
  10. I'm sorry for the typo, it should be:

    Public Sub myMethod (acadapp as autocad.acadapplication)
     
    Jorge Jimenez, May 10, 2004
    #10
  11. Tomas

    Tim Badger Guest

    Jorge, I believe what Tomas is looking for is the ability to use a modal
    dialog box. The way you described works fine for non modal but, as Tomas
    stated, his pick box dissapears when using modal. This is where vba
    simplifies the problem...it allows the use of a modal dialog from an activex
    vb dll.
     
    Tim Badger, May 10, 2004
    #11
  12. In a previous post, I told Tomas to use a vbModeless form.
    He answered that he still had the problem.
    So I was following up on that.

    If I understand him correctly, what he needs to do is to pick a point and
    draw some entities.
    So maybe he doesn't need to come back to the form at all.
     
    Jorge Jimenez, May 10, 2004
    #12
  13. Excuse me, but this isn't true.

    You can see the same problem with VBA, by executing a
    a macro that displays a modal form, via the vla-runmacro
    method from LISP. The vla-runmacro method executes the
    VBA method from the document context (the vl-vbarun
    method and the VBARUN command always execute the macro
    in the application context).

    When a VBA form runs in the document context, it cannot
    be hidden to get command line input. If you try to do
    that, the original call to Show() is blocking, and will
    prevent the document thread from executing. That is why
    AutoCAD does not respond to mouse events.

    If you have a VBA form that hides itself to get command
    line input, try calling the VBA Sub that shows the form
    initially, using VLA-RUNMACRO, and then you should see
    the problem when the form is hidden to get input from
    the AutoCAD window.
     
    Tony Tanzillo, May 10, 2004
    #13
  14. I'm sorry, I was referring to vbmodeless forms.

    From what I understood, Tomas was not
    needing a modal form, since he talked about
    having a button on his form to pick a point
    and after that draw some entities. As this can
    all be done using a modeless form, I wrote
    an example for him, that showed the call to
    "myForm.show" which by default executes
    as a modeless form.

    I'm sure you will agree with me, that "in this case"
    there is no need to call the DLL from VBA, as
    it can be done directly from LISP.

    If he were to use a modal form, then he must make
    the call from a VBA macro.
     
    Jorge Jimenez, May 11, 2004
    #14
  15. Tomas

    Tomas Osers Guest

    Ok, Thank you to all of you

    Every thing it´s working Fine

    I wrote the code that Tim sent me. Thank you

    Regards

    Tomas
     
    Tomas Osers, May 13, 2004
    #15
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.