Runtime
-
In yesterday's post, we looked at a mechanism that has been introduced in AutoCAD 2015 to simplify associating custom data with a Document. In today's post we're going to swap out the custom manager class to make use of the standard UserData mechanism, showing how the PerDocumentClass attribute and the UserData property are actually highly complementary. Here's the updated C# code: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; using System; using System.Collections.Generic; // The all-important attribute telling AutoCAD to instantiate // the PerDocData class for each open or new document [assembly: PerDocumentClass(typeof(PerDocSample.PerDocData))] namespace PerDocSample { public class Commands …
-
I almost named this post to make it clear it's about a new API capability in AutoCAD 2015, but then I wouldn't have had the slightly perverse satisfaction of resurrecting a series of posts after 7.5 years. Here are the first parts in this series, in case you've forgotten them (and you'd be forgiven for doing so, after all ;-). This post is introducing the new PerDocumentClassAttribute capability provided in AutoCAD 2015's .NET API. We're going to look at it over two posts: the first showing how it can be used with your own "manager" class to link the data…
-
I had an email from Martin Duke about this old post a couple of weeks ago. I started to update the original post but then realised that a) I couldn't easily go that far back using Windows Live Writer and the built-in Typepad editor often messes up code in old posts when I edit them and b) there was some value in revisiting this topic again now that nearly 6 years has passed. I'll hopefully manage to link to this updated post from the old one without things going awry. Martin was having some trouble with text display in object…
-
photo credit: Marcin Wichary via photopin cc As mentioned in the last post, fibers are now inactive in AutoCAD 2015 (the code paths are still there, largely for testing purposes, but should not need to be enabled for typical usage of the product). Fibers were a technology that Microsoft introduced way back when to help single document (and typically single-threaded) applications adapt more easily to the brave new world of MDI. At least that's my recollection and understanding. They were basically a mechanism by which applications such as AutoCAD could manage their per-document state, making the relevant data current depending…
-
I've just arrived home from a 10-day trip to the Bay Area. It was a really interesting visit – as usual – but I'm happy to be home (even if I'm writing this at 3am, once again fighting jetlag). The news has started to come out about AutoCAD 2015 – much of it fed by the Autodesk bloggers' day on Monday, which I unfortunately didn't attend – so it seemed timely for me to talk about the updates more from a developer's perspective. Let's look at the major features of AutoCAD 2015, starting with the user interface enhancements. The most…
-
To follow on from yesterday's post, today we're going to look at a reliable way to determine the language of the AutoCAD product hosting your .NET module. Thanks to Troy Louden for sharing this technique. Here's the C# code implementing it: using System.Globalization; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; namespace LanguageInfo { public class Commands { [CommandMethod("LANG")] public static void WhichLanguage() { var cult = new CultureInfo(SystemObjects.DynamicLinker.ProductLcid); Application.DocumentManager.MdiActiveDocument.Editor. WriteMessage( "\nLanguage of your AutoCAD product is {0}.", cult.EnglishName ); } } } When we run the code, we…
-
I'm starting to get ready for a trip to the US: I'm heading out on Monday and will be home on Thursday of the following week. While I expect I'll have time to write a few posts during the trip – thank you, jetlag! – I'm going to write a couple of very simple ones today and tomorrow, just to free up time for preparations. Both posts came out of an internal email discussion on trying to determine the language of the AutoCAD product your application is running in. The initial question was focused on getting this information from the…
-
I'm still on pseudo-vacation. We really had a great week in the snow: sun during the day (everyday!) with the odd bit of fresh snow overnight on a couple of occasions. It's snowing again now, but unfortunately this time it's set to snow all the way through to the end of the day tomorrow, so it's quite possible we'll head home a little earlier than expected. Which, on the plus side, will allow me to do some prep-work for Monday's Geneva Motor Show project installation. Anyway, all this to say that I've written this post really quickly with plenty of…
-
I'm still mainly on holiday this week, so this is a really silly post that I don't realistically expect to be of use to anyone. But then you never know. 🙂 A colleague in Product Support asked me for a quick way to cause AutoCAD to crash, the other day. I didn't ask too much about why he needed to – I trusted he had his reasons – and so went ahead and gave it a try. One very standard way to cause software to crash – at least software that is either written using a pointer-friendly programming language or…
-
Another interesting question came in by email, this week. Fredrik Skeppstedt, a long-time user of the TXTEXP Express Tool, wanted to perform a similar operation using C#: to explode text objects – as TXTEXP does – but then be able to manipulate the resulting geometry from .NET. TXTEXP is an interesting command: in order to explode text objects, it actually exports them to a Windows Metafile (.WMF) using the WMFOUT command, and then reimports the file back in using WMFIN. This, in itself, is trickier than it sounds, as WMFOUT creates the graphics in the file relative to the top…