Loading VBA from LISP (strange behaviour)

Discussion in 'AutoCAD' started by Matthew.Corbin, Feb 27, 2004.

  1. Hello everybody,
    Got a question for you. I've looked all over the net and this NG for a solution to this, but with no help. I am loading my VBA project from a LISP routine using the vbaload, vbarun, etc.... methods. They are all causing the same strange behaviour. When I run the project from the VBAIDE or a button macro I get no problems. When my program starts it shows a few prompts on the command line. First an introduction, then displays the value of a global variable, then it asks for user input in the form of an integer. When I run it from LISP for some reason the intro, the global variable, and "half" of the prompt for user input disappears! I'm sorry I can't post code at the moment, but can tomorrow when i'm back at work. Does this sound familiar to anybody. I'm at a loss on this one. Thanks for any help.
    Matthew Corbin
     
    Matthew.Corbin, Feb 27, 2004
    #1
  2. Good morning everyone,
    Following up on my post from last night. I returned to work with an idea. I found that using

    ThisDrawing.Utility.Prompt

    does NOT work when you call the VBA project from LISP. Can someone test this and help me confirm if this is an issue on my end. All other prompts work, IE a prompt from ThisDrawing.Utility.GetReal (vbCr & "Specify Offset: ")

    Any ideas or info will be greatly appreciated!
    Thanks,
    Matthew Corbin
     
    Matthew.Corbin, Feb 27, 2004
    #2
  3. Matthew.Corbin

    Kevin Terry Guest

    I don't see this problem here, and all of my macros are called with lisp
    shortcuts. Do you have some code you can post, and the lisp as well? One
    thing you might be needing is an extra VBCR before/after the prompt
    string...

    Kevin

    this and help me confirm if this is an issue on my end. All other prompts
    work, IE a prompt from ThisDrawing.Utility.GetReal (vbCr & "Specify Offset:
    ")
     
    Kevin Terry, Mar 1, 2004
    #3
  4. Kevin,
    Here is some of my VBA code (the part that doesn't seem to work)

    Sub PaperSpaceFace()
    'Error handling
    On Error Resume Next
    'Intro
    ThisDrawing.Utility.Prompt vbCr & vbCr & "***PaperSpace Face***"
    'Check for face layer
    Set LayerObj = ThisDrawing.Layers("face")
    If Err <> 0 Then
    Set LayerObj = ThisDrawing.Layers.Add("face")
    LayerObj.Color = acCyan
    ThisDrawing.Utility.Prompt vbCr & vbCr & "Face layer has been added..."
    End If
    'Move to Paper Space
    ThisDrawing.ActiveSpace = acPaperSpace
    'Get the offset value
    Offset = ThisDrawing.Utility.GetReal(vbCr & "Offset Distance: ")

    This all works fine when run from a macro or through VBA.
    I'm using this code to call it from LISP

    (defun c:psf ()
    (command "-vbarun" "g:\psf.dvb!main.paperspaceface")
    (princ)
    )

    What do you think?

    Thanks,
    Matthew Corbin
     
    Matthew.Corbin, Mar 1, 2004
    #4
  5. Matthew.Corbin

    Kevin Terry Guest

    try either of these approaches to the lisp shortcuts instead, maybe that'll
    do it:

    (defun c:BillOfMaterial ()
    (vl-vbarun "BillOfMaterial")
    (princ)
    )

    (defun c:Browser_List ()
    (vla-runmacro (vlax-get-acad-object) "Browser_List")
    (princ)
    )

    I'm not sure why you're doing double carriage returns before your prompt, is
    that just to clear what's visible to the user? (Not that that should make
    any difference, or cause the variation between what you see from vba vs.
    lisp.)

    Kevin
     
    Kevin Terry, Mar 1, 2004
    #5
  6. Kevin,

    I tried your 2nd approach because it was something I hadn't tried yet, and it worked.

    (defun c:psf()
    (vla-runmacro (vlax-get-acad-object) "g:/psf.dvb!main.paperspaceface")
    (princ)
    )

    Very odd though. The double vbcr were to space out the prompts the way I thought looked best. I have tried getting rid of them and that didn't work either. Well at least it works. Very many thanks to you! Consider this one solved (even though I don't know why)
     
    Matthew.Corbin, Mar 1, 2004
    #6
  7. Matthew.Corbin

    Kevin Terry Guest

    great
    :eek:)

    Kevin

    thought looked best. I have tried getting rid of them and that didn't work
    either. Well at least it works. Very many thanks to you! Consider this one
    solved (even though I don't know why)
     
    Kevin Terry, Mar 2, 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.