Blocks

  • I've been meaning to attack this one since we first published the Clipboard Manager as a Plugin of the Month: working out how to display a preview image of the clipboard contents inside the Clipboard Manager palette. And then I happened to receive a request by email, yesterday, suggesting a couple of enhancements to the tool. A nice reminder. ๐Ÿ™‚ 1. Have the clipboard include image previews, similar to that of the wblock command (instead of needing to immediately rename the item when fast copying multiple items). 2. Have the clipboard store items in memory for use in between autocad…

  • Yesterday Scott Sheppard announced the availability of this plugin over on It's Alive in the Lab. We originally received a request for this Plugin of the Month some time ago. Fenton Webb, from our DevTech Americas team, developed the initial version using an ObjectARX custom entity โ€“ as the requester required support for versions of AutoCAD prior to 2010 โ€“ but for this public release, Stephen Preston went ahead and re-implemented the mechanism in a .NET application using the Overrules API introduced in AutoCAD 2010. This plugin basically allows you to see graphically when an AutoCAD drawing is digitally signed,…

  • A big thanks to Thorsten Meinecke for pointing out the obvious issue with my prior post (the nested entity selection loop which has frustrated me unnecessarily when developing the code for that post and another). Here are the details of the fix: using Editor.GetNestedEntity() along with a PromptNestedEntityOptions object, instead of a direct message string, allows us to specify AllowNone to be true. Which, in turn, causes PromptStatus.None to be returned when the enter or space keys are used to terminate the selection loop. An obvious omission, in hindsight, but anyway โ€“ I'm much obliged to you, Thorsten! ๐Ÿ™‚ I've…

  • Here's some simple C# code that asks the user to select an external reference and then detaches it from the current drawing: using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput;   namespace XrefApplication {   public class Commands   {     [CommandMethod("DX")]     static public void DetachXref()     {       Document doc =         Application.DocumentManager.MdiActiveDocument;       Database db = doc.Database;       Editor ed = doc.Editor;         // Select an external reference         Transaction tr =         db.TransactionManager.StartTransaction();       using (tr)       {         BlockTableRecord btr = null;         ObjectId xrefId = ObjectId.Null;           // We'll loop, as…

  • A big thanks to Philippe Leefsma, from the DevTech team in Europe, for providing this handy piece of code in a response to an ADN member. In the last post we saw some code that made use of DBObject.HandOverTo() to maintain identity between an old line and a new one with which we wanted to replace it. This code makes use of this method's counterpart, DBObject.SwapIdWith(), which works on two database-resident objects (rather than the replacement being in-memory, as is the case with HandOverTo()). Here's C# code implementing two commands, to swap the identity (and therefore the order) of two…

  • After seeing Shaan list the results of the latest AUGI wishlist, I started thinking about which of the items would be worth covering either on this blog or via a Plugin of the Month. The second item on the list, "Automatically Differentiate Manually Edited Dimensions", has (hopefully) been addressed by Dimension Patrol, this month's Plugin of the Month, so that's a good start, anyway. The first item, "Change Objects in a Block to a new Layer", seemed as good a good place to start as anywhere. Here's some C# code that builds upon a technique for selecting/highlighting nested entities shown…

  • I received this question by email from Vito Lee: I am trying to write an event handler function in C# and can use your expertise. I am trying to display an alert box whenever a user erases a specific block in a drawing. Which event handler would be best for this situation? This one is interesting, because it's quite a general problem and there are a few ways to solve it. To start with, let's generalise the problem description to cover watching for editing operations on drawing objects. We're indeed going to solve the specific problem stated above โ€“ albeit…

  • In the last post we looked at some code to define a block and insert it into the model-space of an AutoCAD drawing. Today we're going to look at creating a group. Before we dive into the code, it's worth taking a quick look at the difference between a block and a group, to understand the differences between these two container/aggregator objects. I know that much of this information is available elsewhere, but hey โ€“ I'm on a roll, so I request your forbearance. Let's start with looking at the top-level structure of an AutoCAD Database (which is equivalent to…

  • This post โ€“ and its sister post, which will cover creating a group โ€“ are further topics I would expect to have already covered in this blog at some point, or perhaps to see covered by the AutoCAD .NET Developer's Guide (and I'm sure they will be in a future incarnation of it). So thanks to Adam Nagy, from DevTech EMEA, for suggesting these topics. It's nice to go back to basics once in a while (although this means I do have to beg the patience of the readers out there who know this stuff inside out). So, here's some…

  • In response to September's Plugin of the Month - which Shaan has very kindly posted about over on Between the Lines โ€“ a few people have requested enhancements to the OffsetInXref tool. Two came up, in particular: The ability to offset the contents of blocks, not just xrefs The ability to enable the XLINE command's offset functionality to work with xrefs (and blocks) The changes to enable these enhancements are very minor, which is always a pleasant surprise. Well, in the first case it isn't much of a surprise: xrefs are actually just a special kind of block, so we…