AutoCAD
-
Most of the functions to access objects in the AutoCAD drawing return generic objects/entities. The base type for objects stored in the AutoCAD database is "DBObject" – which can be used to access common persistence information such as the handle, etc. – but there is no such thing as a pure DBObject: all DBObjects actually belong to a type that is derived from this base (whether that's a "Line", "Circle", "BlockReference", etc.). The next level up in the hierarchy is "Entity", from where you can access graphical properties such as color, layer, linetype, material, etc. The sample code in this…
-
This post takes the sample code shown in the last entry, converts it to VB.NET and adds in some code to access specific entity properties rather than simply calling list(). I won't step through the code this time, but here's the section of code that gets and dumps out the various entity properties: Dim ent As Entity = CType(tr.GetObject(objId, OpenMode.ForRead), Entity) ' This time access the properties directly ed.WriteMessage(vbLf + "Type: " + ent.GetType().ToString) ed.WriteMessage(vbLf + " Handle: " + ent.Handle().ToString) ed.WriteMessage(vbLf + " Layer: " + ent.Layer().ToString) ed.WriteMessage(vbLf + " Linetype: " + ent.Linetype().ToString) ed.WriteMessage(vbLf…
-
Many AutoCAD commands that work on sets of entities support two styles of working: verb-noun or noun-verb. This basically means that if the user has pre-selected a set of entities (the "noun") and then launch the command (the "verb") then the command will not need to request the user select them. This is enabled using something called the pickfirst or implied selection set inside AutoCAD. To take advantage of this feature inside your commands the first thing to do is to use a special command-flag called "UsePickSet": this tells the AutoCAD editor not to clear the pickfirst set when the…
-
It's been a hectic week, between one thing and another, and I don't expect it to get better anytime soon: apart from anything else, my wife is due to give birth any day to our second child. We're both excited - and admittedly a little anxious - about it, and our 2 year-old seems to be feeding of that, which means none of us have ended getting much sleep of late. All good preparation, I suppose. 🙂 So I decided the path of least resistance for getting a blog entry out today was to look through some of the responses…
-
This was a topic suggested by Scott Underwood (thanks, Scott! 🙂 to look at COM vs. NET and go through their respective advantages and disadvantages… This is really an interesting discussion topic, and one that I'd like people to help turn into an interesting discussion. I can certainly talk about the differences and pros/cons of the two technologies from my own memory/experience/perspective, but others will have things to say on this, I'm sure... please feel free to do so! 🙂 Rather than going into low-level detail on either COM or .NET, I'd suggest looking into their respective Wikipedia sites. Both…
-
Clearly it's far from ideal to ask your users to load your application modules manually into AutoCAD whenever they need them, so over the years a variety of mechanisms have been put in place to enable automatic loading of applications – acad.lsp, acad.ads, acad.rx, the Startup Suite, to name but a few. The most elegant way to auto-load both ObjectARX and .NET applications is the demand-loading mechanism. This mechanism is based on information stored in the Registry describing the conditions under which modules should be loaded and how to load them. Demand loading is fairly straightforward and well documented in…
-
In my previous post I described how you could use the Autodesk.AutoCAD.Runtime.IExtensionApplication interface to implement initialization code in your .NET module. Building on this, we're now going to look at how use of the Autodesk.AutoCAD.Runtime.IExtensionApplication interface can also allow you - with very little effort - to optimize the architecture of your managed modules for faster loading into AutoCAD. First some information from the "Using .NET for AutoCAD documentation" (which is available in the ObjectARX Developer's Guide on the ObjectARX SDK): When AutoCAD loads a managed application, it queries the application's assembly for an ExtensionApplication custom attribute. If this attribute…
-
It's very common to need to execute some code as your application modules are loaded, and then to clean-up as they get unloaded or as AutoCAD terminates. Managed AutoCAD applications can do this by implementing the Autodesk.AutoCAD.Runtime.IExtensionApplication interface, which require Initialize() and Terminate() methods. During the Initialize() method, you will typically want to set system variables and perhaps call commands which execute some pre-existing initialization code for your application. Here's some code showing how to implement this interface using VB.NET: Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.EditorInput Imports System Public Class InitializationTest Implements Autodesk.AutoCAD.Runtime.IExtensionApplication Public Sub Initialize() Implements _…
-
One of the services ADN provides its members is representation of their wishes with Autodesk's Engineering teams, helping influence product direction. For instance, each year we run an API wishlist survey for a number of our products (this year it was AutoCAD, ADT, Revit, Inventor, and Map 3D). An online survey for each product gets filled out by ADN members, allowing them to provide targeted feedback that goes straight to the appropriate Product Management contacts. I wanted to talk about an item that has featured highly in recent AutoCAD API surveys – the exposure of custom objects through .NET. The…
-
Another case of planets aligning: two different people have asked me this question in two days... It's quite common for commands to require users to provide additional input during execution. This information might be passed in via a script or a (command) from LISP, or it may simply be typed manually or pasted in by the user. The fact is, though, that commands don't actually take arguments. It may seem like they do, but they don't. What they do is ask for user input using dialogs or the command-line. Here are a few tips on how to support passing of…