Notification / Events
-
In this previous post we looked at a basic task dialog inside AutoCAD and exercised its various capabilities without showing how they might be used in a real application. This post goes beyond that to show how you might make use of the TaskDialog class to provide your users with relevant information at runtime that helps them decide how best to proceed in certain situations, effectively increasing your application's usability. The specific scenario is this: if the user selects a lot of entities - too many for our command to handle quickly - we want to show a dialog that…
-
This is a topic I've been meaning to get to for some time... as I finally had to research it for a side project I'm working on, I decided to go ahead and post my findings here. AutoCAD 2009 makes heavy use of task dialogs, which are basically message-boxes on steroids. MSDN contains documentation on Microsoft's implementation of task dialogs, although our implementation is a little different. Why bother with these new task dialogs? They provide a way of asking more user-friendly questions using actual actions as answers rather than yes/no/cancel etc. It's a bit like the way I now…
-
Some of you may have stumbled across these previous posts, which show how to add custom context menu items for specific object types and to the default AutoCAD context menu. There is a third way to create and display context menus inside AutoCAD, and this approach may prove useful to those of you who wish to display context menus during particular custom commands. One word of caution: I've been told that this technique does not currently work for transparent commands, so if your command needs to be called transparently then this may not be the approach for you (you should…
-
In response to these recent posts, I received a comment from Nick: By any chance would it be possible to provide an example to prevent a user from using the EXPLODE command for a given block name? I delved into the ADN knowledgebase and came across this helpful ObjectARX DevNote, which I used to create a .NET module to address the above question. Here's the C# code, which should contain enough comments to make it self-explanatory: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; namespace ExplosionPrevention { public class Commands { private Document _doc; private Database…
-
Another big thank you to Jeremy Tammik, from our DevTech team in Europe, for providing this elegant sample. This is another one Jeremy presented at the recent advanced custom entity workshop in Prague. I have added some initial commentary as well as some steps to see the code working. Jeremy also provided the code for the last post. We sometimes want to stop entities from being modified in certain ways, and there are a few different approaches possible, for instance: at the simplest - and least granular - level, we can place entities on locked layers or veto certain commands…
-
The code in the following two posts was provided by Jeremy Tammik, from our DevTech team in Europe, who presented it at an advanced custom entity workshop he delivered recently in Prague to rave reviews. I've formatted the code to fit the blog and added some commentary plus steps to see it working. Thank you, Jeremy! Those of you who are familiar with the workings of AutoCAD Architecture - and especially the Object Modeling Framework - will know of the very cool ability for entities to be anchored to one another. This works because graphical ACA classes derive from a…
-
Back when I joined Autodesk in 1995, I worked in European Developer Support with one of the most talented programmers I've met, Markus Kraus. One of Markus' contributions to the R13 ARX SDK (or maybe it was R14?) was a sample called pretranslate, which remained on the SDK up until ObjectARX 2008, under samples/editor/mfcsamps/pretranslate (it was removed from the 2009 SDK when we archived a number of aging samples). Anyway, with AutoCAD 2009 the API that makes this sample possible has been added to the .NET API, so in homage to Markus' original sample (which I have fond memories of…
-
In the original post in this series, we introduced a basic application to number AutoCAD objects, specifically blocks with attributes. In the second post we extended this to make use of a generic numbering system for drawing-resident AutoCAD objects, and in the third post we implemented additional commands to take advantage of this new "kernel". In this post we're going to extend the application in a few ways: firstly we're going to support duplicates, so that the LNS command which parses the current drawing to understand its numbers will support automatic and semi-automatic renumbering of objects with duplicate numbers. In…
-
Back from a nice long weekend, although I spent most of it sick with a cold. I find this increasingly the way with me: I fend off illness for months at a time (probably through stress, truth be told) but then I get a few days off and wham. A shame, as we had a huge dump of snow over the weekend... we get white Christmases here every five years or so, but it's really uncommon to get a white Easter. I had a very interesting question come in by email from 冷血儿, who wanted to get the technique shown…
-
In the previous posts we looked at some code to link AutoCAD entities via .NET events, and how to persist the link data in the drawing file. This post extends the previous code to automatically link circles into the head of the chain, as circles are drawn by the user. The changes to the project are relatively modest compared to last time. Once again, the source is both available for download and listed below with changed line-numbers in red. Some notes on the changes: First we declare some new variables in our command class: a boolean (m_autolink - line 463)…