Author Topic: Enhanced AutoCAD .NET Project Application Wizard  (Read 20642 times)

0 Members and 1 Guest are viewing this topic.

csharpbird

  • Newt
  • Posts: 64
Enhanced AutoCAD .NET Project Application Wizard
« on: December 07, 2007, 10:01:49 AM »
The original "AutoCAD Managed application wizard" is very simpl. Only the "Autodesk.AutoCAD.Runtime" namespace is imported, but the ObjectARX application often needs other namespaces such as "Autodesk.AutoCAD.DatabaseSevices" and "Autodesk.AutoCAD.ApplicationSevices". Furthermore, you must type "netload" to load the built assembly.
The Enhanced AutoCAD .NET Project Application Wizard solve these problems.
 
Features:
      1.Supports multiple AutoCAD versions
   2.Opens an drawing when AutoCAD is launched
   3.Adds some useful namespace such as Autodesk.AutoCAD.DatabaseServices
   4.Can add AutoCAD COM reference
   5.Adds some often used variables such as database,editor and tranaction
   6.Launches the correct version of AutoCAD when debugging in Visual Studio
   7.Never need to type NetLoad to load the assembly

System Required:1.AutoCAD 2006/2007/2008   2.Visual Studio2005/2008 or C#/VB 2008 express edition

1.Download the suitable version from http://www.codeplex.com/dotnetarx,then unzip it.Double click the .msi setup file,and install the wizard.
 


2.Invoke Visual Studio 2008 IDE then start a new project. Select the node "ObjectARX" under "Visual C# Projects" and click on the template "AutoCAD Managed CS Project Application" as shown below:

 

3.Type in a project name. Set the location where you want the project to be created. Select OK. The "Managed C# Application Wizard For AutoCAD2008" dialog will then appear.

 

4.You can select the AutoCAD version,open a drawing when AutoCAD is launched,add the AutoCAD COM reference to your program, and enable Unmaged debugging.

5.Select the tab "Assemblies&Namespaces" and check the checkbox before the name of the assembly and namespace you want to include in your application. Note: "Autodesk.AutoCAD.Runtime" ,"Autodesk.AutoCAD.DatabaseServices" ,"Autodesk.AutoCAD.ApplicationServices", "Autodesk.AutoCAD.EditorInput" are checked by default because they are often included in the ObjectArx applications, you can uncheck them if your application does not need these namespaces.

 

6.Select the tab "Class" to add summary description for your application and the common used variables such as db,ed,and trans.

 

7.Click "Finish" to accept the settings you have selected.

 

8.Press F5 to debug your application,the correct version of AutoCAD will be launched.You don't need to type "netload",just type the command name you will get the result!
« Last Edit: December 07, 2007, 11:58:41 PM by csharpbird »

quamper

  • Guest
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #1 on: December 07, 2007, 10:25:02 AM »
Thats really awesome.

I love the dialog/form for setting all the options.

And the script that netloads for you is pretty cool.

Thanks for creating this!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #2 on: December 08, 2007, 04:52:53 PM »
Not so nice !

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #3 on: December 08, 2007, 05:05:43 PM »
With ACad2008
VS2008 pro

Downloaded and installed.
Installation completed.
ran VS2008
started wizard.
Wizard failed with error .. no dialog .. 'something unnamed'.

uninstalled.

re-installed

displayed error dialog shown during install setup.


Where are the files installed. ?
How do I ensure a manual removal of ALL files. ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

csharpbird

  • Newt
  • Posts: 64
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #4 on: December 09, 2007, 04:26:21 AM »
With ACad2008
VS2008 pro

Downloaded and installed.
Installation completed.
ran VS2008
started wizard.
Wizard failed with error .. no dialog .. 'something unnamed'.

uninstalled.

re-installed

displayed error dialog shown during install setup.


Where are the files installed. ?
How do I ensure a manual removal of ALL files. ?
It seems that the arxcs.dll file cannot be copied to GAC in your machine.
To solve the problem:
1.Copy arxcs.dll to C:\windows\assembly
2.Copy "AutoCAD Managed CS Application(.NET3.5).zip" file to "My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#"
The two files are in the attachment.
« Last Edit: December 09, 2007, 04:37:44 AM by csharpbird »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #5 on: December 09, 2007, 06:26:20 AM »
Tried that. Different error.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

BeanBag

  • Guest
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #6 on: December 28, 2007, 08:23:46 AM »
Thanks for this - using it with Express 2008 and Autocad 2008.

Your project creation dialogue needs tidying up though - the text is to big for the buttons and and your forgot to finish the word finish. Minor things though  :-P

« Last Edit: December 29, 2007, 04:33:42 PM by BeanBag »

Civbert

  • Guest
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #7 on: May 17, 2008, 05:51:43 PM »
...
Features:
      1.Supports multiple AutoCAD versions
   2.Opens an drawing when AutoCAD is launched
   3.Adds some useful namespace such as Autodesk.AutoCAD.DatabaseServices
   4.Can add AutoCAD COM reference
   5.Adds some often used variables such as database,editor and tranaction
   6.Launches the correct version of AutoCAD when debugging in Visual Studio
   7.Never need to type NetLoad to load the assembly

System Required:1.AutoCAD 2006/2007/2008   2.Visual Studio2005/2008 or C#/VB 2008 express edition

Hi csharpbird,

The "Enhanced AutoCAD .NET Project Application Wizard" is great.  I'm a newbie using VS Express 2008 C# and AutoCAD2008 on Vista.  I used the wizard to create the obligatory  "Hello World" program and hit F5 to debug.  It worked perfectly! 

Then I build the project and tried to run it with AutoCAD - using NETLOAD to load my .dll per the instructions.  When I tied to run my new HelloWorld command, AutoCAD did not recognize the command. 

I'm sure I'm making a newbie mistake.  It works in when I DEBUG, but not when I BUILD it.

BTW.  I tried creating the "HelloWorld" program before installing the "Enhanced AutoCAD .NET Project Application Wizard" and could not debug or get it to work after a build.  So I'm getting closer... :)
« Last Edit: May 18, 2008, 09:23:56 PM by Civbert »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #8 on: May 19, 2008, 01:40:28 PM »
Try attaching your project, so we might have a look  :-)

Civbert

  • Guest
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #9 on: May 19, 2008, 02:08:31 PM »
This is the first attempt (prior to using the Enhanced AutoCAD .NET Project Application Wizard):
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

namespace Lab1
{
    public class Class1
    {
        [CommandMethod("HelloWorld")]
            public void HelloWorld()
        {
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage("Hello World");
            }
 
    }
}
I could not debug this one because it would not launch AutoCAD.  And I could load the .dll with NETLOAD without any errors.  But when I tried to run the new command HelloWorld, I get the "unknown command error".


This is the one using the Wizard:
Code: [Select]
using System;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;

/*Copyright   2008

AutoCAD version:AutoCAD 2008
Description:

To use CsMgd1.dll:

1. Start AutoCAD and open a new drawing.
2. Type netload and select CsMgd1.dll.
3. Execute the HelloWorld command.

Autodesk references added to this project are acdbmgd.dll,acmgd.dll.*/

namespace CsMgd1
{
    /// <summary>
    /// Summary for HelloWorld.
    /// </summary>
    public class HelloWorld
    {

        Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
        [CommandMethod("HelloWorld")]
        public void Hi()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("Hello World");
        }
    }
}


This one actually worked when I hit F5 to Debug it.  It launch AutoCAD and loaded the .dll, and I could enter the HelloWorld command and it works.   And even though I could build the program without error, just like before, I could not run the command after NETLOAD-ing the .dll . 

Civbert

  • Guest
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #10 on: May 21, 2008, 12:15:45 PM »
I figured out what the problem was - and it was not with the Wizard or with the 2008 Visual C# or the objarx or with AutoCAD 2008.  It turns out it was my ActiveWords program. 

AW is a cool program that CAD users should love.  It allows you to open documents, folders, launch programs, and much more, using your keyboard.  I hardly ever use my mouse to open AutoCAD or Outlook, or open project folders on the company server.  I just type in my custom command and hit F8 (or double space or enter or whatever you set up.)

However, for some reason, when I launch AutoCAD using ActiveWords, I loose a bunch of my commands and I can not load programs using NETLOAD.  No error message is given, but the commands will not work after I load the .dlls.   But everything works in CAD when I launch it from the desktop icon, or by going directly to acad.exe in explorer.  I can even NETLOAD my dll and they work.  HellowWorld works now!

The fix came from ActiveWords support right away. (Those guys are great!)  The showed me how I could have ActiveWords run a script that would launch AutoCAD from Windows "Run" command tool.  Works like a charm.  Now I can use ActiveWords to launch AutoCAD (cad F8) and everything works fine.

Also, the Wizard works fine too.  I can create custom dlls in Visual C# Express Edition (2008) and really debug them!  Before the Wizard, I could only build them and see if they worked.  The Express Editions of Visual Studios does not give you a way to run AutoCAD to help you debug your program.

So now things are going fine.  My ActiveWords is working great and I highly recommend that program.  http://www.activewords.com/ The Wizard works great too.  And now I can continue on my path of learning how to create custom commands for AutoCAD using C# and .NET. 

I do have one question for csharpbird.  How does he get the Express edition of VS to launch AutoCAD in debug?  I've been digging around in the code and I can not find it.  It's great, but can I do it without using the Wizard to set up my projects?

Thanks.
« Last Edit: May 25, 2008, 12:33:13 PM by Civbert »


csharpbird

  • Newt
  • Posts: 64
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #12 on: May 25, 2008, 10:09:02 AM »
The new version of "Enhanced AutoCAD .NET Project Application Wizard" has been released!
You can download from https://www.codeplex.com/dotnetarx

The new version supports AutoCAD2006/2007/2008/2009 and Visual Studio 2008.

Dimas1

  • Guest
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #13 on: June 04, 2008, 01:53:50 AM »
thanx for the wizard. the description looks great)
unfortunately was unable to install arxcs.dll to GAC
install utility asks for a key
do you happen to have one?

csharpbird

  • Newt
  • Posts: 64
Re: Enhanced AutoCAD .NET Project Application Wizard
« Reply #14 on: June 05, 2008, 02:45:47 AM »
Hi,Dimas
For Visual Studio 2005,you can copy arxcs.dll to \Program Files\Microsoft Visual Studio 8.0\Common7\IDE.
For Visual Studio 2008,use the new version of "Enhanced AutoCAD .NET Project Application Wizard" .