Autocad within a Windows Form

Autocad within a Windows Form

Anonymous
Not applicable
897 Views
3 Replies
Message 1 of 4

Autocad within a Windows Form

Anonymous
Not applicable
This is probably a question that has been asked and answered, but I need a little direction.

I have inherited a VB application that communicates with AutoCAD via the AutoCAD dll properties and methods (Autodesk.AutoCAD.Interop and Autodesk.AutoCAD.Interop.Common). The basic functionality of the application is to link CAD Objects to SQL data via the Handle (Stored in the SQL DB), and pass data between the database and Object when actions are initiated by the VB application.

I would like to reengineer this application to be a little more usable, but have some questions as to what is the best method, based on what is available since this source code was written circa 2002. Ideally, I would like the VB application to have a control(?) that contains the AutoCAD drawing / environment, which would allow pushing data to the drawing from the VB app and trap in VB when selecting an object in CAD, rather than having to switch between VB app and CAD drawing. The other issue is that I have to recompile the application with the latest AutoCAD dlls every time a new CAD version is released (pretty much every year), and the application needs to support all recent versions of AutoCAD (can live with 2006 forward, if optimal solution eliminates need to recomplie each year).

The application really doesn't need to manipulate the drawing, other than setting the text and possibly the ability to position a text object.

What I would like to have happen is for:
- VB App establish connection to dwg file (perferably in a window / control on the VB form)
- VB App to choose objects on appropriate layer and select that layer in the drawing
- VB App to choose SQL record to link to CAD object
- Clicking on a CAD object in the selected layer passes it's Handle back to VB
- VB App to create a text object centered over the CAD object
- VB App to push information back to the new CAD text object
- (Optional) ability to manipulate the text object

Any suggestions / success stories / source code samples ?
0 Likes
898 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
This is a bump to my previous post. Can anyone answer basically point me to a decent resource for training or code examples for working with CAD with .NET?

I would ideally like to create an app that is stand-alone and controls CAD, rather than a custom add-in to autocad.

Anyone with success in this area that would like to share?

Thanks,

Mark
0 Likes
Message 3 of 4

Anonymous
Not applicable
If you want to create a stand alone app that opens autocad, you will have to use the COM object to open it. If you don't want it to be version specific you can late bind the AutoCAD object but then you will be limited to the COM API of the earliest release you want to use.

As far as opening an autocad session in a windows form and controlling it from there, that is way beyond me.

However, why not do the opposite? Open autocad and create a windows form and load it into Autocad. This is more inline with what an end user would probably expect anyways. You will be able to control the drawing however you wish and still access windows components as you would in a normal windows form.

Help for the Interop libraries will be found under the VBA section of the help files. Under your Autocad install directory, there is a help folder which has a bunch of help files including acadauto.chm and acaddev###.chm.

If you want more info on programming AutoCAD using the .NET managed libraries then you should look at the labs and objectARX SDK. Links to both below. The managed API is (IMO) the way to go.

Good Luck,
-Mark

Links to the developer center - .NET training and Labs
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627

ObjectARX SDK
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=773204
0 Likes
Message 4 of 4

Anonymous
Not applicable
If you want to drive AutoCAD or create/read/edit dwg files from outside of AutoCAD your options are very limited.
Autodesk has one option called RealDWG.
Google can help you find other options.
0 Likes