TheSwamp

Code Red => .NET => Topic started by: csharpbird on December 07, 2007, 10:01:49 AM

Title: Enhanced AutoCAD .NET Project Application Wizard
Post by: csharpbird 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 (http://www.codeplex.com/dotnetarx),then unzip it.Double click the .msi setup file,and install the wizard.
 
(http://farm3.static.flickr.com/2207/2094874670_1700f96c33_m.jpg)

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:

 (http://farm3.static.flickr.com/2246/2094874812_592f742378_m.jpg)

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.

 (http://farm3.static.flickr.com/2255/2094102183_b73faec5ed_m.jpg)

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.

 (http://farm3.static.flickr.com/2247/2094102463_0132e9f2c8_m.jpg)

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

 (http://farm3.static.flickr.com/2185/2094874472_b47cf309e8_m.jpg)

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

 (http://farm3.static.flickr.com/2319/2094101647_f39ca5dfc5_m.jpg)

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!
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: quamper 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!
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Kerry on December 08, 2007, 04:52:53 PM
Not so nice !

Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Kerry 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. ?
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: csharpbird 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.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Kerry on December 09, 2007, 06:26:20 AM
Tried that. Different error.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: BeanBag 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

Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Civbert 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... :)
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: It's Alive! on May 19, 2008, 01:40:28 PM
Try attaching your project, so we might have a look  :-)
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Civbert 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 . 
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Civbert 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/ (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.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: sinc on May 21, 2008, 08:50:27 PM
http://www.theswamp.org/index.php?topic=20223.msg245802#msg245802
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: csharpbird 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.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Dimas1 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?
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: csharpbird 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" .
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Dimas1 on June 06, 2008, 08:23:43 AM
ok, I'll try doing this with Studio 2005
but how to install this great wizard in 2008?(
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: csharpbird on June 06, 2008, 10:56:23 AM
ok, I'll try doing this with Studio 2005
but how to install this great wizard in 2008?(
http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=13734
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Dimas1 on June 08, 2008, 08:17:11 PM
http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=13734
great( another link to install packadge. You mean if I download it again it should magically start working?)
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Chumplybum on July 22, 2008, 06:51:24 PM
csharpbird, i've been using your .net template flawlessly for ages now and recently had to reinstall visual studio

anyway, i downloaded that latest version of your .net application wizard (http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=13734) and i get the following error when starting a new project with the 'AutoCAD Managed VB Application' template...

Error: this template attempted to load an untrusted component 'ArxCS2008,Version=1.0.0.0, Culture=Neutral, PublicKeyToken=18313633467130a4'.
         For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates.

i'm using VB express 2008 (also get the same error in C# express 2008) with AutoCAD 2008

any thoughts?


cheers Mark
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: A_LOTA_NOTA on September 13, 2008, 11:22:23 AM

I'm getting this error during install. Anyone know why & how to fix it?




(http://www.theswamp.org/screens/ARX%20error.gif)
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: wannabe on December 04, 2008, 02:24:44 PM
csharpbird, i've been using your .net template flawlessly for ages now and recently had to reinstall visual studio

anyway, i downloaded that latest version of your .net application wizard (http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=13734) and i get the following error when starting a new project with the 'AutoCAD Managed VB Application' template...

Error: this template attempted to load an untrusted component 'ArxCS2008,Version=1.0.0.0, Culture=Neutral, PublicKeyToken=18313633467130a4'.
         For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates.

i'm using VB express 2008 (also get the same error in C# express 2008) with AutoCAD 2008

any thoughts?


cheers Mark

Was a solution to this ever ascertained?
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: gile on December 04, 2008, 03:17:33 PM
Hi wannabe,

I use C# 2008 Express too but with "Enhanced AutoCAD .NET Project Application Wizard For C#/VB 2008 Express" you can find on this page (http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=8881).
It's not the last version but fine for me (as far as I use it).
It seems that the last version require Visual Studio 2008 'plain version'.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: wannabe on December 04, 2008, 03:56:45 PM
Hi wannabe,

I use C# 2008 Express too but with "Enhanced AutoCAD .NET Project Application Wizard For C#/VB 2008 Express" you can find on this page (http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=8881).
It's not the last version but fine for me (as far as I use it).
It seems that the last version require Visual Studio 2008 'plain version'.

thanks. It says something about a null value in an error message.

Cheers anyway.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: dustinthiesse on February 23, 2009, 03:27:00 PM
csharpbird, i've been using your .net template flawlessly for ages now and recently had to reinstall visual studio

anyway, i downloaded that latest version of your .net application wizard (http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=13734) and i get the following error when starting a new project with the 'AutoCAD Managed VB Application' template...

Error: this template attempted to load an untrusted component 'ArxCS2008,Version=1.0.0.0, Culture=Neutral, PublicKeyToken=18313633467130a4'.
         For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates.

i'm using VB express 2008 (also get the same error in C# express 2008) with AutoCAD 2008

any thoughts?


cheers Mark

Was a solution to this ever ascertained?

I get this exact same error.  Using C# express 2008 and AutoCAD 2008.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: vegbruiser on November 23, 2009, 11:06:21 AM
csharpbird, i've been using your .net template flawlessly for ages now and recently had to reinstall visual studio

anyway, i downloaded that latest version of your .net application wizard (http://www.codeplex.com/dotnetarx/Release/ProjectReleases.aspx?ReleaseId=13734) and i get the following error when starting a new project with the 'AutoCAD Managed VB Application' template...

Error: this template attempted to load an untrusted component 'ArxCS2008,Version=1.0.0.0, Culture=Neutral, PublicKeyToken=18313633467130a4'.
         For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates.

i'm using VB express 2008 (also get the same error in C# express 2008) with AutoCAD 2008

any thoughts?


cheers Mark

Was a solution to this ever ascertained?

I get this exact same error.  Using C# express 2008 and AutoCAD 2008.
I too am now seeing this error - I think it's something to do with the Express versions of VS 2008 - it works fine in the full version.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Glenn R on November 23, 2009, 04:25:59 PM
Use the Autodesk one that was released recently.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: vegbruiser on November 23, 2009, 05:40:53 PM
I don't suppose you have a link for it - I think I remember reading about it - just not where.

EDIT: Found it: -

*removed*

:D

EDIT: seems my original link wasn't to the "latest" version - use Kerry's link instead.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Kerry on November 23, 2009, 05:46:18 PM
http://images.autodesk.com/adsk/files/autocad_2010_dotnet_wizards.zip

via
Developer Center
http://usa.autodesk.com/adsk/servlet/index?id=1911627&siteID=123112
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: vegbruiser on November 23, 2009, 05:53:36 PM
Thanks Kerry.

EDIT: I apologise if someone else has already posted this (admins please remove this post if so):

Using Kerry's link I found the official AutoCAD .NET Developers Guide (http://www.autodesk.com/autocad-net-developers-guide) which will really come in handy.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: mohnston on November 25, 2009, 02:07:36 PM
Using Kerry's link I found the official AutoCAD .NET Developers Guide (http://www.autodesk.com/autocad-net-developers-guide) which will really come in handy.

One would think, but sadly it is not handy (or helpful) at all.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: vegbruiser on November 26, 2009, 03:18:22 AM
Using Kerry's link I found the official AutoCAD .NET Developers Guide (http://www.autodesk.com/autocad-net-developers-guide) which will really come in handy.

One would think, but sadly it is not handy (or helpful) at all.
In what way?;

I've been looking at the guide with a view to getting some assistance for creating layouts, inserting borders on those layouts and creating the viewports needed, and although it shows how to create viewports and create/insert blocks, it doesn't detail how to put it all together.*  I've done this sort of thing using vba so assumed the steps necessary were the same. I can't be the only person that wants to do this, so why haven't they given some good examples that do more than one task?

*At least, I haven't seen it if it does.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: Kerry on November 26, 2009, 04:16:05 AM

Mark,
I think I fills a niche.
Admittedly, it would be better in a transportable form, but if you know how, it can be downloaded, and examples of non-preferred language can be edited out.
Admittedly, it would have been handy to have a few years ago, but it is giving current starters a consistant set of examples.

... and I'm not going to bemoan the fact that it could be more detailed in several areas ... half of something is better than all of nothing, and AutoDesk should be encouraged to continue their efforts.

Regards
Kerry
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: mohnston on November 27, 2009, 07:44:00 PM
Try finding anything on attributes, palettes or xdata.
These are just a few examples of common items that I think should be in any cad programming help system *especially* the company that provides the software.
I picked those 3 examples because the help system left me without help.

Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: sinc on November 28, 2009, 08:09:36 AM
Just as a note, I've found Autodesk's documentation teams to be very responsive to feedback.  Much more so than any other group at Autodesk.

Every time I've given feedback on the documentation, I've gotten an almost immediate response from the documentation team.  They really like feedback, and they WILL change the documentation in response.
Title: Re: Enhanced AutoCAD .NET Project Application Wizard
Post by: vegbruiser on November 30, 2009, 10:52:38 AM
Thanks for the info sinc, perhaps we should compile a list and send it to them?