Bare with me..miracle I have got this far...
VS2010
AutoCAD 2011
Got a LISP routne that NETLOADs a .net DLL..which reads an XML file and returns values via "LispFunction - resultBuffer"
The DLL had a form with 2 buttons
Button 1 - Locates an XML file..then creates a bunch of arrays...blah..blah..and does its thing
Button 2 - Exit
Here is my question...and I would think this would be very simple..
When Ithe user hits the EXIT button....I want the .NET app to EXIT and return back to AutoCAD (LISP)...without doing anything..you know, your typical EXIT...
For the life of me I can't figure it out....when I Select the EXIT button...I get an FATAL ERROR end AutoCAD mustbe stopped....
Solved! Go to Solution.
Solved by chiefbraincloud. Go to Solution.
Solved by gopinath.taget. Go to Solution.
Hi Jerry,
I need more information to tell what is going wrong:
1) Where in the .NET application are you launcing the FORM?
- Are you using the AutoCAD .NET "Initialize" routine?
- Are you calling from a Lisp Callable method (that has an Attribute LispFunction)?
I can however tell you what I would do to achieve what you want:
1) Create an AutoCAD .NET application
2) Create my Form to do my thing
3) Create a LispFunction method. This is a method in .NET that can be called directly from a lisp as if it is a lisp function. If your unfamiliar with LispFunction, please take a look at this blog post: http://through-the-interface.typepad.com/through_the_interface/2006/07/breathe_fresh_l.html
4) Show the Form in this LispFunction method as modal form using the Application.ShowModalDialog API method. This will make sure that the LispFunction method does not return to the Lisp application immediatly after displaying the Form
5) Do your thing with Form and then return out of the LispFunction.
This will automatically return control to the lisp application after the form is closed/exited.
Hope this helps.
Cheers
Gopinath Taget
Autodesk Developer Network
thx...
You explaining exactly what I am doing....
When the form is called...there are 2 buttons....one that does stuff....then returns to the LispFunction call to do more stuff..then exits back to autoacad.
What I am looking for...is when the other button is selected on the form (The EXIT button)..how to I return back to the Lispfunction call....do nothing....then back to AutoCAD...
In a simple VB app..this is easy...but this..AutoCAD Lisp -> Neload -> LispFunction -> Form -> Lispfunction -> AutoCAD thing makes it difficult for me to do this...and I know it should be very easy....
Hi Jerry,
Does the crash occur in Exit before the Application.ShowModalDialog returns? If not, did you check for the return value of this method when exit button is pressed?
You can also access the return result using the Form.DialogResult property. You should be able to use this to distinguish between the returns of the two buttons and behave differently based on the button pressed.
Cheers
Gopinath Taget
Autodesk Developer Network
My guess is that you are experiencing a problem similar to one I had when I first started playing around with LispFunctions.
I had trouble figuring out the right way to basically Return Nothing. What you have to do (or what I had to do) was declare my LispFunction return type as ResultBuffer (I had been returning as ObjectId) and return a ResultBuffer created with New TypedValue(LispDataType.Nil).
Thanks guys...the combination of.....form.DialogResult.......and.......TypedValue(LispDataType.Nil)....did the trick
You might be want to play around as well:
VB.NET
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.StartUserInteraction(Me)
C#
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.StartUserInteraction(this);
in the form class