Migrating AutoCAD COM API applications to AutoCAD 2010

1. Change your CreateObject and GetObject calls from “AutoCAD.Application.17” to “AutoCAD.Application.18”

2. Change the reference “AutoCAD” from “AutoCAD 2009 Type Library” to “AutoCAD 2010 Type Library” (Autodesk.AutoCAD.Interop)

3. Change the reference “AXDBLib” from “AutoCAD/ObjectDBX Common 17.0 Type Library” to “AutoCAD/ObjectDBX Common 18.0 Type Library” (Autodesk.AutoCAD.Interop.Common)

See also:

http://autocad.autodesk.com/?nd=autocad_tips_tutorials_detail&adsk_tip_id=676&jid=2036

 

You will probably have to make some extra changes when reading/saving .dwg’s but I have yet to check those problems.

Posted by Bert Vanpeteghem 2 reacties

Revit API introduction webcast

Note to self: Jeremy Tammik posted a webcast on the Revit API: http://thebuildingcoder.typepad.com/blog/2009/05/revit-api-introduction-webcast.html

Posted by Bert Vanpeteghem 0 reacties

Rarities: another CAD .NET blog

I found another blog (partially) focused on .NET in AutoCAD. I didn’t know that there existed one next to Through The Interface…

So, here it is: http://bobbycjones.spaces.live.com/blog/

And he might just have brought me a solution to a problem I’ve been facing today: He mentiones that when using Database.ReadDwgFile, you ALWAYS need to dispose that.

I’ve been struggling with random AccessViolationException error’s when trying to set Block Properties. This might solve it… Let’s hope so.

Posted by Bert Vanpeteghem 1 reacties

Disable and restore Code Analysis for all projects in a solution

Code Analysis is a Visual Studio tool that can analyze your code and warn you about bad practices and plain bad code.

It can be a very handy tool that can lift your code to a higher level and allows you to simply create better and more maintainable applications.

However, having code analysis enabled, severely slows down your build. Changing a little thing in code causes Code Analysis to run on the next build, which can be plain annoying.

For these reasons I have created a little Visual Studio Add In, which can disable Code Analysis on all projects in the currently opened solution, and can restore the initial settings.

The project home is: http://code.google.com/p/codeanalyzethis/

You can download the source  here: http://code.google.com/p/codeanalyzethis/downloads/list

Or you can check out the source with SVN: svn checkout http://codeanalyzethis.googlecode.com/svn/trunk/

I am not familiar with administering Open Source so I just picked the GNU GPL v3 licence. If anyone has any considerations towards the licence, please let me know.

Posted by Bert Vanpeteghem 0 reacties

Using App.Config with AutoCad

In Winforms projects, it is quite common to use app.config. For instance, to store settings  and application parameters etc. When programming AutoCad extensions, you’ll run into problems: trying to address the default app.config file leads you to the app.config of the running process, being AutoCad. AutoCad has provided a solution for this (although it would be possible to do this yourself): they created an acad.exe.config.

Placing your application settings in acad.exe.config lets frameworks like Unity, Enterprise library and your own application to run correctly after all. This solution is not perfect, and still causes lots of problems with Unity, but there must be workarounds. This, again, might be interesting for a more extensive blog post on the subject. Just let me know if this is desired…

Posted by Bert Vanpeteghem 2 reacties

Geometry and Algebra libraries

Have you ever spent too much time figuring out a difficult algorithm with AutoCAD API’s Vectors and Matrices? I feel I have. In fact, I know I have. Last year, I needed several algorithms, such as Point In Polygon, Bounding Boxes and Convex Hull. I looked up the algorithms on Wikipedia or some other computational library, and I found mostly C or C++ code doing the job.

I know these languages, but I don’t use them all the time. It also seemed like a waste of time trying to write them in C# or VB. And it looked ugly as hell. Searching a little bit further, I found that these libraries actually already exist. More importantly, they are also very extensive and Open Source! These libraries are mostly GIS-oriented, but can definitely be used in CAD calculations too. A polygon is a polygon, no?

The most important one I found is Topology Framework, this is actually a collection of libraries with slight modifications and renamings. There are several frameworks referenced by this one. And they can all be found under the Credits section.

Today, I read the following blogpost. It mentions a numerical library providing mathematical functions for .NET. I haven’t looked into it in detail, but if you’re no longer happy with the Math namespace in .NET, this might be worth checking out: dnAnalytics

I might do a post on how to use these frameworks together with the AutoCad API, so if you’re interested, let me know…

Posted by Bert Vanpeteghem 0 reacties

Screencast on fluent interfaces

Ever since I’ve used Fluent NHibernate I’ve become a big fan of Fluent interfaces. There is something very sexy, but more important, literally ‘fluent’ about using them.

Within possibilities I have been trying to implement the technique in my own coding & frameworks. While doing that, I found that it is really important to have a clear strategy, before starting to create all types of methods returning the ‘this’ object.

For example, when creating wrapper classes for selections in AutoCad, the Fluent styles seem very appropriate. (Note to self: blogpost ;).

Anyway, there is a great screencast up on Dimecasts about creating Fluent Interfaces. The screencast is not very extensive, but gives a nice overview and strategy on creating them.

Posted by Bert Vanpeteghem 0 reacties