Drawing structure
-
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…
-
As a comment on this previous post, MikeR posted this request: Hi Kean, I'm the one that instigated this original question about group filters. That part is working fine and I can also set the active group filter in the file. Now I need to make parent & child filters. How can I add child filters to an existing parent filter at the root? Thanks, Mike The below code is an update of that shown previously, the main addition being the CNLG command to create a nested layer group. I also took the chance to fix a minor bug (I…
-
This is a really fun one: a new technology preview on Autodesk Labs that integrates powerful sketching – such as that available in SketchBook Pro and SketchBook Mobile (both of which I've played around with, at one point or another) – into AutoCAD 2010. Now it's not immediately apparent what the benefits are for having this kind of sketching integrated directly into AutoCAD, but for sure it saves application switching and is likely to make it easier to share marked-up models. The first thing I did was to install the application: To sketch you need to be in a layout,…
-
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…
-
Sometimes I receive a question which makes me think "I must have posted something that shows that by now, surely?" and yet I can't find it. So please accept my apologies if this post is redundant and I'm just repeating myself. 🙂 Here's the question that had me thinking: I don't know how may I create a new layer in drawing. And here's some code I threw together to show this. It defines a simple command called CL which creates a layer with the name proposed by the user, after validating the name using the SymbolUtilityServices namespace (which I admit…
-
Thanks to Philippe Leefsma, from DevTech in Europe, for the ObjectARX code that inspired this post. In AutoCAD it's possible to create non-rectangular viewports in paperspace using a variety of closed curve objects: circles, polylines (2D, 3D and lightweight), ellipses, regions, splines and faces. In this post we're going to see some code that creates four new viewports in the paperspace of the active drawing using a subset of these objects: an Ellipse, a Circle, a closed Spline and a closed Polyline. Here's the C# code: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry; namespace ViewportCreation {…
-
A philosophical question regarding the Layer Reporter tool came up in a recent discussion with Tony Tanzillo. Tony suggested that using XML and XSLT would have been a better way to implement the tool, and in many ways I agree with him (I've been an advocate of XML for many years… during my interview to join Autodesk back in 1995 I presented a session on "Electronic Publishing Formats", which covered HTML generation from SGML – a pre-cursor to XML – and since then I've used XML regularly and on quite significant projects, such as during the redesign of the ADN…
-
I feel like I'm posting a lot about our Plugin of the Month initiative, at the moment, but then I suppose it's to some degree a function of what I'm spending time on. It's definitely eating into the time I would normally focus on blogging… after a number of AU-related posts coming out over the next few weeks (as I finish my AU prep next week and then blog from the event the week after) I'd hope to return to somewhat more typical posts in December (although as I'm going on to Japan, Korea and China from Las Vegas, this…
-
In the most recent part of this series, we looked at one possible mechanism to allow points to be moved along a network of curves, extending the first part in this series, which focused on the case of a point on a single curve. This post is going to focus on something slightly different: it's going to look at making the points added to a particular curve be associative to that curve – i.e. travel along with it as the curve is moved – and in the process we're going to adjust the way we link between our objects, by…