AutoCAD .NET
-
To accompany the last post – which raised some questions around when and where to call Dispose() on objects created or accessed via AutoCAD's .NET API – today we're going to look at a few concrete examples. Thanks to Danny P for not only requesting some examples but also presenting some concrete areas he wasn't fully clear on. Let's start by looking at those (and feel free to compare the responses I've put below with the ones I made in direct response to Danny's original comment): Within a transaction where something is added to the database, some new objects (Xrecords,…
-
This is a follow-on to this previous post, prompted by a thread over on The Swamp discussing a recent blog post by Fenton Webb on the AutoCAD DevBlog. Fenton's assertion is that you really need to call Dispose() on all AutoCAD objects that you create yourself, unless they are managed by AutoCAD's transaction system (i.e. you've passed responsibility across to AutoCAD by calling Transaction.AddNewlyCreatedDBObject()). Which means that while you don't need to call Dispose() on objects such as the AutoCAD Editor or the active Document (and you really shouldn't), you really should call Dispose() on various objects you've been used…
-
Earlier in this series, we implemented a jig to rotate, size and place text more easily in an AutoCAD drawing, which we then extended to allow adjustment of font-level properties. In this post, we're going to add some additional functionality to allow the text to be justified differently around the cursor location. It has to be said that the code introduced in this post isn't very extensive, but nonetheless tricky to get right (and therefore deserving of its own post). It's also worth noting that the changes would be much more complicated if we hadn't designed the code to add…
-
In the last post, we saw a simple jig implementation to position, size and rotate standard AutoCAD text. In this post, we're extending that implementation to handle font properties such as bold and italic text. At first blush, this sounds pretty straightforward – how hard can it be, right? The complexity gets introduced when we consider that these are not properties that are exposed directly from the text itself, but from the associated text style (or – to be more accurate – from the font descriptor object associated with the text style). Which begs the question: when the user chooses…
-
Back in March, I received an email from Thomas Fitou suggesting an interesting blog topic: I was thinking about a cool feature in jigs: You invoke a command to enter an Mtext or text The editor is asking for some text You enter the text Then a jig is dragged asking for position But in the editor appear some options:[R]egular [B]old [I]talic [R]otate 90 If the user hits "B" the text becomes bold If the user hits "R" the text is rotated 90 degrees If the user hits "R" again, another 90 degrees and so on... It struck me as…
-
As mentioned in this previous post, I was very keen to see how AutoCAD could be used to help streamline the process of generating what I've now found out can be classified as anamorphic street art. Leon Keer had mentioned that the technique dates back to Leonardo Da Vinci and – sure enough – Wikipedia agrees. As part of my research, I found the original video that inspired my interest in Leon's work, which should help put this post in context: To make the process reasonably realistic – and to some degree replicate the approach Leon has taken in his…
-
In the last few posts on this topic, we saw some examples of getting information from and controlling AutoCAD via its Bindable Object Layer. In this post, we're going to look at a way to find out when changes are made to AutoCAD's layer table: when layers are added, changed or removed. There are certainly other ways to do this: you can use Database.ObjectAppended(), ObjectModified() and ObjectErased() to find out about changes to LayerTableRecords, for instance, but this is an alternative approach that may be interesting to some people. In this implementation, we attach some event handlers to keep an…
-
After looking at how the Bindable Object Layer (BOL) in AutoCAD might be used to get information about the current drawing, in today's post we're going to see how it can also be used to manipulate that data (in a fairly limited, albeit useful, way). But first, let's talk a bit about the origins of the BOL. It was first introduced as an architectural feature of AutoCAD when we were looking at delivering AutoCAD for Mac. It's common, these days, for programming frameworks to provide some kind of data-binding facility to simplify the creation of UIs: both WPF and Cocoa…
-
Some time ago, I posted code that used the Autodesk.AutoCAD.Windows.Data namespace to list the hatch patterns in the current drawing. Fenton Webb posted a follow-up on the AutoCAD DevBlog that took this further, extracting additional data from AutoCAD and using it to populate an Excel spreadsheet. Within that post, Fenton showed the technique required to access and iterate across other data collections – something I hadn't managed to do when creating my original post. Rather than repeat exactly what Fenton has put together – which is really nice, do take a look at it – I'm just taking a small…
-
After discovering, earlier in the week, that version 1.5 of the Kinect SDK provides the capability to get a 3D mesh of a tracked face, I couldn't resist seeing how to bring that into AutoCAD (both inside a jig and as database-resident geometry). I started by checking out the pretty-cool FaceTracking3D sample, which gives you a feel for how Kinect tracks faces, super-imposing an exaggerated, textured mesh on top of your usual face in a WPF dialog: I decided to go for a more minimalist (which also happens to mean it's simpler and with less scary results 🙂 approach for…