AutoCAD .NET

  • Thanks once again to Viru Aithal for the inspiration behind this post, although I did write most of the code, this time. ๐Ÿ™‚ Adding a splash screen can give a touch of class to your application, assuming it's done non-intrusively. This post focuses on how best to do so within AutoCAD, and use the time it's displayed to perform initialization for your application. The first thing you need to do is add a Windows Form to your project: You should select the standard "Windows Form" type, giving an appropriate name (in this case I've used "SplashScreen", imaginatively enough). Once this…

  • Now this may seem like a very trivial post, but this was actually a significant problem for my team when preparing the material for the Autodesk Component Technologies presentation we delivered at last year's DevDays tour. Basically the "type" (or really "sub-type") of a Solid3d (an AcDb3DSolid in ObjectARX) is not exposed through ObjectARX and therefore neither is it exposed through the managed interface. It is possible to get at the information from C++ using the Brep API, but this is currently not available from .NET (and yes, we are aware that many of you would like to see this…

  • It's often desirable to show a progress meter during lengthy operations. Although there's currently no public API to make use of AutoCAD's progress meter from .NET, there are nevertheless a couple of approaches to doing so. In this post I'll show how to do this using P/Invoke (using some code borrowed from Fenton Webb, from DevTech Americas) and in my next post I'll show how to use the "internal" AutoCAD managed assembly. Here's the C# code that uses P/Invoke, which should work for AutoCAD 2007 and 2008: using Autodesk.AutoCAD.Runtime; using System.Runtime.InteropServices; using System.Windows.Forms; namespace ProgressMeterTest {   public class Cmds…

  • In the last post we looked at a jig that can be used to add block references to an AutoCAD drawing. This post extends that code to support annotative block definitions (available from AutoCAD 2008) and blocks with attributes. Thanks once again to Holger Steiner for the jig class and to Roland Feletic for posting the code to support annotative blocks. A comment on the previous post asked about having attributes visible during the jig process: unfortunately that's not currently possible, as the existing managed AttributeCollection implementation wraps the version of the AcDbBlockReference::appendAttribute() ObjectARX function that requires the block reference…

  • A big thanks to Holger Seidel from CADsys for proposing this topic and providing the bulk of the code. My main contribution - aside from some minor edits - was to implement the logic in the "BJIG" command to allow selection of the block and then loop to multiply insert it. The jig definition is almost entirely Holger's. The below C# code essentially implements a streamlined "multiple insert" command, without the options to scale or rotate the block (this would be very simple to add, of course). The code was written for AutoCAD 2007-2008. The only change you should need…

  • I started to address this topic during this previous post, but it seemed like it was worth coming back to. This time I'm looking at a different technique: to create our own partial CUI file programmatically using the Autodesk.AutoCAD.Customization functionality, save it to disk and then make sure it's loaded at the beginning of every subsequent AutoCAD session. I'm not going to focus on adding menus etc. into AutoCAD's list - that's left for a future post - this is mainly about the logic needed to make sure a CUI is created and loaded. Here's some C# code I put…

  • To follow on from the last post, we're now going to take a look at adding custom menu items to the default context menu in AutoCAD. The default menu appears when the user right-clicks on the drawing but has no objects selected. This is a good place to put application commands, for instance. The approach is very similar to the previous one, although I've added some additional commands to control adding and removing the various menus in addition to relying on the module's initialization callback. Some other notes: We're not just adding a single menu item, but are using a…

  • It's been quite a week - between interviews for a DevTech position we're working to fill in Beijing and AU proposals (my team managed to pull together and submit nearly 60 API class proposals at the beginning of the week) life has been extremely hectic. Thankfully we're now in the middle of the "May Day Golden Week" here in China. The Chinese government schedules three Golden Weeks every year - one for Spring Festival, one for Labour Day (also known as May Day) and one for the National Day. They're basically week-long holidays formed by a few standard holidays and…

  • In the last post we looked at how to add a new annotative scale to an AutoCAD drawing. In this post we'll look at what's needed to make an object annotative - providing it's of a type that supports annotation scaling, of course. Once again, this post is based on functionality introduced in AutoCAD 2008. I hit my head against the problem for a while, having tried my best to convert the technique shown in the AnnotationScaling ObjectARX sample (which uses a protocol extension to access objects stored in an annotative entity's extension dictionary) to .NET. I finally ended up…

  • Thanks to Nikolay Poleshchuk and Roland Feletic for suggesting this topic, and to Wayne Brill, from DevTech Americas, for providing the code. In this post we're going to look at some functionality that's specific to AutoCAD 2008 - adding a new annotative scale to a drawing. The next post (assuming I can work out how to do it ๐Ÿ™‚ will cover how you can attach a scale programmatically to make an entity annotative. Firstly, I should cover what the annotation scaling feature is all about... Here's a quick overview from the AutoCAD 2008 online help: Objects that are commonly used…