AutoCAD .NET
-
Another quick post, as I'm just about to head back home after a long week in Boston. This post comes from a technical solution provided by Sreekar Devatha, from DevTech India. I won't go into detail regarding the following code, but it should be fairly clear what's going on: from a particular colour-name it looks up a colour from a color-book (yes, I know I've used "colour" and "color" in the same sentence, but "color-book" is an AutoCAD term and it's hard for me to drop my u's when I don't have to, even after having lived in the US…
-
In parts 1 & 2 of this series we looked at metaprogramming with AutoCAD using AutoLISP and VB(A), and then using VB.NET and C#. In this post we're going to look at what's possible from F#, through the lens of my relative inexperience with the language, of course. The quotations mechanism in F# appears to be the way to represent, analyse and execute program structure. This article describes the concepts, although it's quite deep and doesn't address the case that's most immediately interesting to AutoCAD develeopers: the ability to evaluate and execute code represented as a string. In fact, this…
-
In this post we're going to continue the topic started in Part 1 of this series, which looked briefly at metaprogramming with AutoCAD using AutoLISP and VB(A). Now we're going to look at .NET, focusing initially on C# and VB.NET. [I found the inspiration for the code in this post from The Code Project, although I had to update the code to use non-deprecated CLR methods as well as making it work for AutoCAD, of course.] While .NET doesn't provide something as simple as an Eval() function, it actually provides something much more interesting. The CLR exposes the ability to…
-
A recent comment on one of my F# articles got me thinking about this topic (thanks, Thomas! :-), so I thought I'd write a few posts on it. Next week is AU, and the week after that I'm attending a training class in Boston, so posts may be a little sparse over the coming weeks. Metaprogramming – according to the definition on Wikipedia – is the act of writing code that writes or manipulates other programs (or itself). But what is it really all about? The vast majority of programmers are actually metaprogramming without realizing it has such a fancy…
-
In one of my sessions at this year's AU, "There's More to .DWG Than AutoCAD®", I'll be showing some VB.NET code that goes through and collects information about solids, presenting it in a dialog along with the sum of the various volumes. You can get the code and the results from Part 1 of the session's handout. Just for fun, I thought I'd write some F# code to add the volumes of the 3D solid objects in the modelspace of the current drawing. I adopt a similar approach to the VB code - not caring about intersecting volumes, for instance…
-
I've been working through some draft chapters of Don Syme's Expert F# book (posted here, while the final version will be available in hardcover from early December). I'm definitely enjoying working with F#: the beauty of functional programming combined with the flexibility of .NET is a killer combination. Before I dive into the sample I put together for today's post, I thought I'd scribble down some musings on the language, to help position the technology in comparison with more popular imperative/object-oriented languages... Functional programming is great for deep mathematical problems, and so will play well with developers needing to perform…
-
For my follow-up F# post I wanted to find something that showed off more of the capabilities of the F# language, while remaining something worth integrating with AutoCAD. The good news (at least as far as I'm concerned 🙂 is that one of the samples that ships with F# turned out to be perfect for this. The sample is known as "The Famous DirectX Demo", and is really, really cool. It uses F# to represent - extremely succinctly - a simulated, animated surface. And when I say succinct I mean it's tiny: with F# it's possible to represent complex mathematical…
-
I couldn't resist... I just had to have a play with this technology, today. 🙂 Here are the steps to get your first (very simple) F# application working inside AutoCAD. First we need to download and install the latest F# distributable from here (at the time of writing this was the July 31 release - 1.9.2.9). We create a base F# project, selecting the "F# Project" template: We now add a new item to the project of type "F# Source File" to the project: The file created contains a lot of boilerplate code that is definitely worth looking at to…
-
I've just come across the announcement for F#, and am pretty excited about it. Here's the link to Soma's blog, and here's the Microsoft Research F# site. F# is a functional programming language. Functional programming has a long association with technical computing, one of the reasons LISP was chosen as the initial programming interface for AutoCAD. On a personal note: aside from the work I've done with LISP over the years, I also studied an obscure functional language called Miranda during my university days and have since worked a lot with XSLT (which is at least influenced by functional languages).…
-
Introduction This session focuses on technologies that can be used to view and access DWF content downstream from Autodesk's design products. Yesterday's session focused on DWG – we're going to take the model containing 3D solids that we created during that session and publish it to DWF, adding custom metadata. We can then look at how to harness this data in lightweight applications, whether to access it non-graphically or to view it. Firstly, why are we using 3D solids in this example? The choice was somewhat arbitrary – the point is really to demonstrate the ability to access properties of…