AutoCAD .NET
-
This post extends the code shown in the last – very similarly named – post, to work on a specified drawing, that – very importantly – does not get loaded into the AutoCAD editor. Step 2 in the list for this series: Implement a command to collect RegAppId information for the active document Extend this command to work on a drawing not loaded in the editor Save our RegAppId information to some persistent location (XML) Create a modified version of ScriptPro 2.0 (one of our Plugins of the Month) to call our command without opening the drawing The code starts…
-
Many of you will be aware of what has been referred to as the "RegAppId virus": drawings that have been unfortunately polluted with excessive Registered Application IDs – which are used by applications to attach XData to entities – have these RegAppIds brought into a main drawing when Xrefed, duplicating and duplicating IDs that were often redundant in the first place. In fact – back in the day – I remember a very popular 3rd party application (which has long since been fixed and shall remain nameless) that erroneously used to create hundreds (if not thousands) of these IDs in…
-
Yesterday my two sons – who are now 6 and 4, both great ages – managed to get me to sit (several times, of course) on a whoopee cushion. Which brought back many fond memories of my brother and I playing similar tricks at around that age. What amazed me most was how the technology has advanced: this latest generation of cushion self-inflates! A simple enough innovation – the rubber now contains a small hole and a sponge – but in many ways revolutionary. Ah, if only I had a time machine I could make a small (but very noisy)…
-
This request came in over the weekend: There is a useful object snap in AutoCAD for the mid point of 2 selected points. I would like a midpoint (average) of 3 (or more) points. Could this work in 3D as well as 2D? It's useful when drawing building surveys, often you triangulate a point from several and there are often 'minimal' differences in the dimension and you just take the average. Given the fact we're actually talking about an arbitrary number of points that will almost certainly not belong to a single entity, object snaps are probably neither the easiest…
-
I owe Chris Kratz a huge thanks for inspiring me to do more with LINQ. This post uses LINQ to provide more elegant solutions to a couple of problems described in previous posts. The code in today's post is probably my second brief foray into the world of LINQ. The comments Chris posted on the last post prompted me to spend a little time looking at LINQ over the weekend, and I really like it. I'd heard before that "LINQ is really just functional programming", and in many ways I see that more clearly now, myself: the set of higher-order…
-
Thanks to Virupaksha Aithal, from DevTech India, for providing the technical response to an ADN member than inspired this post. When working with the Point2d and Point3d objects from AutoCAD's .NET API it's common to use the in-built collection types, Point2dCollection and Point3dCollection. Neither of these objects provides the capability to sort their contents (and, in any case, sorting would mean different things to different people when it comes to containers of objects with multiple data entries). So how can you sort one of these collections? The answer is fairly straightforward: you convert them to a .NET array, sort them…
-
From time to time I listen to the .NET Rocks show – I don't get the chance to listen every week, but I do browse through the RSS items I get for the show episodes and find some time to put those I find of particular interest on in the background while I'm working on something else. Yesterday's episode caught my eye, as it focused on the nKinect project, exposing the Kinect's capabilities to .NET. And 'm really (and I mean really) excited about the Xbox Kinect. I mentioned it in passing in a post from last March (it was…
-
Thanks for Chris, Dan and Dale for pointing out the obvious issue(s) with my last post. Let's just blame it on a few holiday cobwebs needing brushing away during the first week back in the saddle. 🙂 The main issue with my previous implementation was that I'd somehow forgotten that Database.Insert() allows you to insert into a named block definition. This simple function does all my previous, manual approach did and more. The secondary issue – but still very important to those using annotation scaling – is that the previous code does not work for annotative blocks, as Dan very…
-
Important note: the code in this post – while potentially interesting, at a certain level – has been superceded by the code in the following post. Please go ahead and use that simpler, more complete implementation instead. This question came in, over the holidays, that seemed like it was worth addressing: How do I get an external DWG into the blocks table as a block definition? I started by quoting this ancient (at least in terms of this blog) post, but it turned out only to be of partial help: the problem is that the external DWG does not contain…
-
As Scott has announced over on his blog, January's Plugin of the Month, DrawOrder By Layer, is now available on Autodesk Labs. I first posted the code for this very useful plugin back in October, and this version includes only a very minor change from that one (for performance reasons it now only works with modelspace layers). A huge thanks to Terry Dotson from DotSoft for generously donating this plugin. After the original post, a few people provided feedback on user interface enhancements they'd like to see in the tool – thanks for taking the time to do so, those…