AutoCAD .NET
-
It's been a hectic week and I haven't been able to find much time to work on a final post for today, so I had a quick delve in my "interesting" folder and found this little gem. Not long ago, someone asked me by email about the reason for making the various co-ordinate properties (X/Y/Z) of Autodesk.AutoCAD.Geometry.Point2d and Point3d read-only, essentially making these classes immutable. Being a big fan of functional programming, I can think of lots of good reasons for immutability, most of which (and more) have also been given to justify the logic behind making System.String an immutable…
-
A developer had an interesting requirement that I thought I'd spend some time looking at: to animate transient graphics inside AutoCAD according to data they've pulled in from an external simulation system. It's clear that AutoCAD is really not an animation platform – we have other products that are better suited to working in this way – but I thought it would be interesting to see what was possible. I decided to take the implementation shown in this previous post and throw in some code to animate a few different things: Change the per-vertex colours of our transient box These…
-
This question came in recently by email: I have reached a snag when trying to find the boundaries of external references that have been "xclipped" by the user. Or, to be more precise, I can't even really find the data telling me whether or not the external reference has been "xclipped" at all. I'm wondering if you have any idea how or where I could find this data. While I found this previous post showing how to perform an XCLIP, I couldn't find anything showing how to query for XCLIP information. Here's some C# code that does just that for…
-
In the last post, we introduced some code to generate transient graphics using WorldGeometry.Shell(). In this post we'll make one simple addition: we'll add per-vertex colours, to see the effect on the generated box. We're not going to perform complex calculations to determine the appropriate colours for each vertex: we'll just use the index of the vertex itself, in much the same way as we did for the faces. As faces and vertices in no way match, index-wise, we should see some interesting effects. Here's the modified C# code. There is only one addition to the previous code: a call…
-
Since posting about the ability to display transient graphics as an ongoing feature that can react to mouse input, I've been thinking of the steps that would be needed to generate a custom gizmo comparable with AutoCAD's viewcube. The post starts to go in that direction by displaying a couple of types of transient graphics in AutoCAD as a "standard" feature: firstly we're going to show screen-fixed text (with code pulled directly from this post) and then we're going to place a a transient box in the drawing itself. This may be pre-cursor to displaying a box-like gizmo, but then…
-
Many, many thanks to Massimo Cicognani for contributing the code in today's post. Massimo contacted me as he was working through some issues with his implementation and then kindly offered to share it with this blog's readers. We've looked at a few different types of overrule on this blog, in the past, and even taken a look at a grip overrule or two. Massimo's much more advanced grip overrule works with a very particular type of polyline: those that alternate between straight and arc segments (with the first and last segments being straight). This might sound a touch specific, unless…
-
This question came in by email, last week: I'm trying to reverse the direction of a polyline thought the API, but I didn't find something in the documentation nor in the web. (Even nothing on your blog.) Can you help me? I also didn't find anything in the public API, although that doesn't mean there isn't something I've missed (I seem to be on a bit of a roll in that respect, lately :-S :-). A couple of thoughts/comments on this problem: Ideally we don't want to create a brand new object, as on the one hand there may be…
-
An interesting question came in via email from Rob Outman. He's interested in applying a selection filter when the user selects dynamic blocks. This is straightforward for unmodified dynamic blocks – just as with standard blocks, you can filter on the block name very easily – but it works less well on dynamic blocks whose properties have been modified at an instance level. Essentially what happens is this: if you select a block reference to a dynamic block in the AutoCAD editor and then use (for example) the Properties window to edit some of the custom properties associated with that…
-
This is a really interesting topic. At least I think it is – hopefully at least some of you will agree. 🙂 The requirement was to create selectable – or at least manipulatable – transient graphics inside AutoCAD's drawing canvas. As many of you are probably aware, transient graphics are not hooked into AutoCAD's selection mechanism. This is mostly fine, but if you want to implement a ViewCube-like gizmo that manipulates the view or drawing settings in some way, it's hard to do so without the ability to react to the current cursor position is and what's happening with the…
-
After the first three parts of this series covered the basic jig that makes use of the standard keywords mechanism to adjust text's style and rotation as it's being placed, it eventually made sense to implement the remaining requirement initially provided for the jig: this post looks at different approaches for having the jig respond to single keystrokes rather than full keyword inputs. Dave Osborne very helpfully got me started on this by providing an initial implementation that makes use of an IMessageFilter – something he'd apparently gleaned from this previous post. Thanks, Dave! 🙂 All the approaches I'll outline…