Author Topic: Windows Forms  (Read 3277 times)

0 Members and 1 Guest are viewing this topic.

wannabe

  • Guest
Windows Forms
« on: February 27, 2009, 07:12:58 AM »
Is it a simple case of creating a windows form application, then using the forms and toolbox objects supplied with visual studio/.NET, to use forms in an AutoCAD app?

Maybe a few examples would be good?

sinc

  • Guest
Re: Windows Forms
« Reply #1 on: February 27, 2009, 07:59:30 AM »
I usually create a project of type Class Library, and netload it into Autocad, possibly using IExtensionApplication.

wannabe

  • Guest
Re: Windows Forms
« Reply #2 on: February 27, 2009, 09:00:46 AM »
Apologies if that answers my question. But I couldn't infer that it did.

So basically, I've read two C# books; C# 2008 for dummies (read twice) and I'm nearing completion on an exercise-based manual, that has a lot of Windows Form Application tasks.

As for Acad, well I've read the third-party .NET developers guide, studied code on here and regularly read, and re-read, Kean Walmsley's blog.

So now I wan't to get coding and I want to start by revamping some of our company's LISP routines by making them form driven and enhancing their dynamism where possible.

I've not seen any form-based code, unfortunately, hence my request.

 :-)

Cheers
 
Nick

sinc

  • Guest
Re: Windows Forms
« Reply #3 on: February 27, 2009, 10:48:16 AM »
Is there a particular reason you want to use a separate application?

I usually prefer to create a project type "Class Library" in visual studio, then netload the Class Library into Autocad, rather than create a separate application that interacts with Autocad.  You can do either, it just depends on your goals.

I think it's easier to netload a class library into Autocad, though.  Then you use the "CommandMethod" attribute to define methods as commands, and you can call your commands by typing commands at the Autocad command line.  I'm sure you've seen lots of examples of that in Kean's blog.

And yes, you can just create Windows Forms or User Control elements, and use them in your code when you do this.  You just don't create a full-fledged Application Project, and don't create a Main() method.  The entry point(s) to your code are defined by the "CommandMethod" attributes.  (Or by implementing IExtensionApplication, which you probably don't need to worry about right now...)

Glenn R

  • Guest
Re: Windows Forms
« Reply #4 on: February 27, 2009, 12:39:48 PM »
Search for the AutoCAD .NET Labs...they show what you're after me thinks.

wannabe

  • Guest
Re: Windows Forms
« Reply #5 on: February 27, 2009, 03:07:46 PM »
Do you know, it's just clicked. A form application is an executable and would be a totally stupid idea.

The .NET labs I did a while ago, but when I wasn't so comfortable with C# language. Definitely something I will re-visit.

Thanks for your comments.

Glenn R

  • Guest
Re: Windows Forms
« Reply #6 on: February 27, 2009, 04:24:16 PM »
A 'form application' as you call it, can be a dll and in AutoCAD's case always is (unless you do an 'out of process' proggy, which is another kettle of fish as they say).

TonyT

  • Guest
Re: Windows Forms
« Reply #7 on: February 27, 2009, 05:26:15 PM »
Do you know, it's just clicked. A form application is an executable and would be a totally stupid idea.

The .NET labs I did a while ago, but when I wasn't so comfortable with C# language. Definitely something I will re-visit.

Thanks for your comments.

The confusion will disappear over time with experience.

A "Form application" is an executable. 

A "Classlibrary" is a DLL, which is what All AutoCAD managed
extensions are.

The confusion you're having is that you are assuming that
you must use a FormsApplication to use a form, which is not
the case. You can create forms in any managed project
whether it is an executable or a DLL.

Just start with the Wizard and create a standard ClassLibrary
project, then add references to acdbmdg.dll and admgd.dll,
along with references to System.Windows.Forms and to
System.Drawing (the latter two are needed to create and use
forms).

Then, from the solution explorer, right click on your project
and choose Add New Item, and in the dialog select a form.

If you've been studying C# and the AutoCAD api, then you
should already be familiar with building a basic AutoCAD
extension dll, with an IExtensionApplication, and one or more
commands.

wannabe

  • Guest
Re: Windows Forms
« Reply #8 on: February 28, 2009, 06:41:15 AM »
Definitely hit the nail on the head there with regards to my incorrect understanding.

Comments and simplified explanations appreciated.

wannabe

  • Guest
Re: Windows Forms
« Reply #9 on: March 02, 2009, 08:16:31 AM »
So basically, because CAD supports the .NET framework then all components of this can be utilised in CAD.

sinc

  • Guest
Re: Windows Forms
« Reply #10 on: March 02, 2009, 10:21:21 AM »
In a sense...

.NET is really the managed API for Windows.  Autodesk also has a managed API for Autocad.  So, you can use a managed language such as C# to do development, and you have access to the Windows .NET API, as well as the Autocad managed API.