AutoCAD close error..... (A challenge)

AutoCAD close error..... (A challenge)

Anonymous
Not applicable
287 Views
4 Replies
Message 1 of 5

AutoCAD close error..... (A challenge)

Anonymous
Not applicable
I have a vba sub, lets say...

Public Sub MyStuff()
call VLstuff ' where VL is some Vlisp I'm calling in VBA using the
ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
if then
do some stuff
end if
end sub

If I run this function either through a form I load with a (vl-vbarun
"MyForm") or from the command line -vbarun MyStuff, AutoCAD is happy....

However:
If I have a (defun c:MyCommand()(vl-vbarun "MyStuff")) AutoCAD will throw up
a Runtime Visual C++ Error: application abnormally terminated.

The function runs just fine. AutoCAD doesn't look like it has any problems.
Just after you close the drawing and then exit AutoCAD it throws up this
error......... I susspect the problem is with the Vlisp activex, but no clue
on how to work around it - other than not making a MyCommand and just using
toolbars..... And why running it from a form causes no error, who knows?
0 Likes
288 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
How about if you try this:

(defun c:MyCommand()(command "-vbarun" "acad.dvb!MyStuff"))

Jeff
--
Jeff Spannbauer
Civil Engineer III
Cannon Associates
www.cannonassoc.com
805-544-7407


"Aaron Rumple" wrote in message
news:7AB2FA76EA986E60EBF8812C85735427@in.WebX.maYIadrTaRb...
> I have a vba sub, lets say...
>
> Public Sub MyStuff()
> call VLstuff ' where VL is some Vlisp I'm calling in VBA using the
> ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
> if then
> do some stuff
> end if
> end sub
>
> If I run this function either through a form I load with a (vl-vbarun
> "MyForm") or from the command line -vbarun MyStuff, AutoCAD is happy....
>
> However:
> If I have a (defun c:MyCommand()(vl-vbarun "MyStuff")) AutoCAD will throw
up
> a Runtime Visual C++ Error: application abnormally terminated.
>
> The function runs just fine. AutoCAD doesn't look like it has any
problems.
> Just after you close the drawing and then exit AutoCAD it throws up this
> error......... I susspect the problem is with the Vlisp activex, but no
clue
> on how to work around it - other than not making a MyCommand and just
using
> toolbars..... And why running it from a form causes no error, who knows?
>
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
My first thought is that maybe the function doesn't finish, until the VB
macro finishes,
which effectively holds-up the command line. Stale mate.

Brian D.

"Jeff Spannbauer" wrote in message
news:E4AE943610C1A1B7577CD02F74E0ADBB@in.WebX.maYIadrTaRb...
> How about if you try this:
>
> (defun c:MyCommand()(command "-vbarun" "acad.dvb!MyStuff"))
>
> Jeff
> --
> Jeff Spannbauer
> Civil Engineer III
> Cannon Associates
> www.cannonassoc.com
> 805-544-7407
>
>
> "Aaron Rumple" wrote in message
> news:7AB2FA76EA986E60EBF8812C85735427@in.WebX.maYIadrTaRb...
> > I have a vba sub, lets say...
> >
> > Public Sub MyStuff()
> > call VLstuff ' where VL is some Vlisp I'm calling in VBA using the
> > ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
> > if then
> > do some stuff
> > end if
> > end sub
> >
> > If I run this function either through a form I load with a (vl-vbarun
> > "MyForm") or from the command line -vbarun MyStuff, AutoCAD is happy....
> >
> > However:
> > If I have a (defun c:MyCommand()(vl-vbarun "MyStuff")) AutoCAD will
throw
> up
> > a Runtime Visual C++ Error: application abnormally terminated.
> >
> > The function runs just fine. AutoCAD doesn't look like it has any
> problems.
> > Just after you close the drawing and then exit AutoCAD it throws up this
> > error......... I susspect the problem is with the Vlisp activex, but no
> clue
> > on how to work around it - other than not making a MyCommand and just
> using
> > toolbars..... And why running it from a form causes no error, who knows?
> >
> >
>
>
0 Likes
Message 4 of 5

Anonymous
Not applicable
What release of AutoCAD?

Is your form modal or modeless?

Does your form hide itself temporarily to get
input from the AutoCAD window?

What does your "vlstuff" do?

Try it this way and see if still happens:

(defun C:MYCOMMAND ()
(vla-runmacro (vlax-get-acad-object) "MyStuff")
)

"Aaron Rumple" wrote in message
news:7AB2FA76EA986E60EBF8812C85735427@in.WebX.maYIadrTaRb...
> I have a vba sub, lets say...
>
> Public Sub MyStuff()
> call VLstuff ' where VL is some Vlisp I'm calling in VBA using the
> ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
> if then
> do some stuff
> end if
> end sub
>
> If I run this function either through a form I load with a (vl-vbarun
> "MyForm") or from the command line -vbarun MyStuff, AutoCAD is happy....
>
> However:
> If I have a (defun c:MyCommand()(vl-vbarun "MyStuff")) AutoCAD will throw
up
> a Runtime Visual C++ Error: application abnormally terminated.
>
> The function runs just fine. AutoCAD doesn't look like it has any
problems.
> Just after you close the drawing and then exit AutoCAD it throws up this
> error......... I susspect the problem is with the Vlisp activex, but no
clue
> on how to work around it - other than not making a MyCommand and just
using
> toolbars..... And why running it from a form causes no error, who knows?
>
>
0 Likes
Message 5 of 5

Anonymous
Not applicable
Problem solved thanks!... but
FYI: The problem isn't in the form, but the command line version of the same
command.
The window which has toolbuttons is modeless using acfocusctrl. However it
never is hidden.
Calling "MyStuff" from a form button works fine as I said and no error is
given on acad close.
Running vbarun "MyStuff" from the command line does not give an error on
acad close.

Only when (command "vbrun" "MyStuff") or (vl-vbarun "MyStuff") is used does
the error pop up.

(vla-runmacro (vlax-get-acad-object) "MyStuff") does not give an error.

Inside the vba function I am calling Vlisp to make my own GrRed function...
Set vlReturnGR = VLisp.ActiveDocument.Functions.item("read").funcall("(setq
ReturnPoint (cadr (grread 1)))")

Hope that helps others...

"Tony Tanzillo" wrote in message
news:C0B80D69C9CA66EEA335BDCE15F05792@in.WebX.maYIadrTaRb...
> What release of AutoCAD?
>
> Is your form modal or modeless?
>
> Does your form hide itself temporarily to get
> input from the AutoCAD window?
>
> What does your "vlstuff" do?
>
> Try it this way and see if still happens:
>
> (defun C:MYCOMMAND ()
>
> )
>
> "Aaron Rumple" wrote in message
> news:7AB2FA76EA986E60EBF8812C85735427@in.WebX.maYIadrTaRb...
> > I have a vba sub, lets say...
> >
> > Public Sub MyStuff()
> > call VLstuff ' where VL is some Vlisp I'm calling in VBA using the
> > ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
> > if then
> > do some stuff
> > end if
> > end sub
> >
> > If I run this function either through a form I load with a (vl-vbarun
> > "MyForm") or from the command line -vbarun MyStuff, AutoCAD is happy....
> >
> > However:
> > If I have a (defun c:MyCommand()(vl-vbarun "MyStuff")) AutoCAD will
throw
> up
> > a Runtime Visual C++ Error: application abnormally terminated.
> >
> > The function runs just fine. AutoCAD doesn't look like it has any
> problems.
> > Just after you close the drawing and then exit AutoCAD it throws up this
> > error......... I susspect the problem is with the Vlisp activex, but no
> clue
> > on how to work around it - other than not making a MyCommand and just
> using
> > toolbars..... And why running it from a form causes no error, who knows?
> >
> >
>
>
>
>
0 Likes