I posted the example without seeing your code, and
a bit of explaination about the example may be helpful.
If a member function marked with the CommandMethod
attribute is not static, then AutoCAD is going to create
one instance of the containing class, for each drawing in
which the command is issued.
That means that if you have three drawings open in the
AutoCAD editor, and you issue the CheckProfile command
in each of them, then there will be three instances of your
getData class, one for each open document. Hence, there
will be three instances of your dataGatheringForm created
as well.
That scheme can be extremely useful in cases where the
form binds or couples to document-specific data. If the form
does not couple to document specific data, you may not
want to have multiple document-specific forms, and rather
have a single form that is used in all documents.
The choice of which way to go is largely dependent on the
nature of the form and the application it is a part of.
Just so that everyone knows, the sample I posted shows
how to display a single modal form that is used in every
open document, rather than use multiple document-specific
forms.
Lastly, Bobby's advice regarding showing the form, is not
correct for forms in managed applications loaded into the
AutoCAD process.
Instead of calling ShowDialog() or Show() to display your
form, in AutoCAD you would call the ShowModalDialog()
method of the Apolication object. For a modeless dialog,
there is the ShowModelessDialog() method. There are
several things that these methods do, which are desireable
in the case of AutoCAD-hosted winforms. So, you should
use those in lieu of the aforementioned Form methods.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
"Homer Simpson" wrote in message news:4897738@discussion.autodesk.com...
I've been trying to do that but the intellisense won't display the
showdialog or show methods for the instance. The code is inserted below. I
also have one form named 'dataGatheringForm' in the project. Any suggestions
are greatly appreciated.
Thanks,
Scott
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Windows;
namespace ProfileChecking
{
public class getData
{
[CommandMethod("CheckProfile")]
public void ShowForm();
{
Form dataForm = new dataGatheringForm();
// dataform. intellisense not working as expected...
}
}
}
"Bobby C. Jones" wrote in message
news:4897582@discussion.autodesk.com...
Hi Scott,
To display a form simply create an instance of it and call its .Show or
.ShowDialog method.
--
Bobby C. Jones
http://www.acadx.com
"Homer Simpson" wrote in message
news:4897447@discussion.autodesk.com...
Hi Everyone,
I've been working with CommandMethod to create some AutoCAD commands that
interact with the user through prompts and messagebox display. Next, I want
to start using Winforms but I can't find any examples and the "trial and
error" approach has been failing me. I have the forms designed but can't
display them. I'm using AutoCAD 2006 and VS2005 Beta 2 on Windows XP SP2.
Any suggestions?
Thanks,
Scott