AutoCAD .NET
-
As mentioned in this previous post, my team delivers regular webcasts on programming with Autodesk technologies. Assuming you're reading this while the metaphorical ink's still damp, it's still not too late to register for a class being held on Thursday October 16th at 8am Pacific, 5pm CET: AutoCAD: .NET for LISP Programmers. Otherwise you should be able to find a recording of the webcast on this page within a few weeks of the session being delivered. In fact, here's the recording of the last time this session was delivered (although it may well have been updated slightly, as the session…
-
As mentioned in this previous post, I had the great pleasure of spending a day up at Microsoft Research in Cambridge last week. My host, Don Syme, took great care of me and was very generous with his time and knowledge. Some background on why I decided to request a meeting with Don: Don is the person behind F#, a new programming language that has, over the last year or so, transitioned from being a research project to a fully-fledged .NET language with full support in Microsoft's development tools. Expect to see the capability to create F# projects (just as…
-
The code used as the basis for this post was from a recent response sent out by Philippe Leefsma, from our European DevTech team. Thanks, Philippe! It's very common to want to manipulate an entity programmatically in AutoCAD, and often the best way to do so is to "transform" it. The technique is very straightforward: you create a transformation matrix using the static members of the Matrix3d class (Displacement(), Rotation(), Scaling(), Mirroring(), or the possibly less commonly needed AlignCoordinateSystem(), Projection(), PlaneToWorld() and WorldToPlane()), you make sure your entity is open for write, and then simply pass the matrix into the…
-
A question came in on a previous post: Hello, I write applications for Autocad Map and Civil3d platforms, mostly with ObjectARX. I would like to do more with .NET but so far the main reason preventing this is not having the NETUNLOAD command.. With arx I can just arxunload and arxload the application for modifications in a second. But with .NET I have to restart the heavy environment and do all kinds of lengthy initializations before being able to try even small changes in code, this can take a minute or more.. Maybe it is possible to create an utility,…
-
The following question came in as a comment on this previous post: Your example above shows how to create a property type filter, how do you add layers to a group type filter (LayerGroup class)? I can create the group filter but can't figure out how to add layers to the group. The filterexpression method is available but doesn't seem to work (at least not like with the LayerFilter object) To tackle this, let's start by looking at the documentation on the LayerGroup class in the .NET Reference (currently part of the ObjectARX Reference): LayerGroup is derived from LayerFilter and…
-
The question of how to perform a "NETLOAD" programmatically has come in a few times. Well, it turns out the answer - provided by someone in our Engineering team - is refreshingly simple. The NETLOAD command actually has a bare-bones implementation: the hard work of parsing the metadata defining commands etc. is done from an AppDomain.AssemblyLoad event-handler. To recreate the NETLOAD command, all you need to do is call Assembly.LoadFrom(), passing in the path to your assembly. Here's some C# code to demonstrate this: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using System.Reflection; namespace LoadModule { public class Commands { …
-
I'm still a little frazzled after transcribing the 18,000 word interview with John Walker (and largely with two fingers - at such times the fact that I've never learned to touch-type is a significant cause of frustration, as you might imagine). I'm also attending meetings all this coming week, so I've gone for the cheap option, once again, of dipping into my magic folder of code generated and provided by my team. The technique for this one came from a response sent out by Philippe Leefsma, from DevTech EMEA, but he did mention a colleague helped him by suggesting the…
-
This is an interesting one that came up recently during an internal discussion: During my module's Initialize() function, I want to decide that the module should not actually be loaded. How can I accomplish that? The answer is surprisingly simple: if you throw an exception during the function, AutoCAD's NETLOAD mechanism will stop loading the application. For an example, see this C# code: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; namespace PreventLoad { public class Commands : IExtensionApplication { public void Initialize() { // This will prevent the application from loading …
-
Since posting three different options for Zooming to a Window or Entity inside AutoCAD, I've had a few discussions with a developer on how best to implement this cleanly. The requirement is to change the AutoCAD view via a smooth view transition (currently not exposed via any kind of view-modification API, only via the ZOOM command), but also to hide the fact we're sending commands to the command-line to do so. While we were discussing, I remembered an old friend, the NOMUTT system variable, which allows almost all command-line noise to be filtered out - even the "Command:" prompt disappears.…
-
This just may be the catalyst I needed to get around to installing Visual Studio 2008: the availability of the F# September 2008 Community Technology Preview. This takes F# an important step closer to being a full .NET citizen, with the first release delivered by Microsoft's Developer Division (the previous releases having been delivered by Microsoft Research). It's not required to use VS 2008 with this release of F#, but that's the version that's been targeted for the IDE integration, naturally enough. I've been holding off from installing VS 2008 for some time - mainly as ObjectARX applications still require…