A blog for developers programming with Autodesk platforms, particularly AutoCAD and Forge. With a special focus on AR/VR and IoT.

81 posts categorized "F#"

February 13, 2012

Following on from the previous post in this series, today’s post completes the implementation to create a full Apollonian gasket in AutoCAD using F#. As a comment on the original Common LISP implementation, someone had contributed a more complete version which allowed me to complete today’s F# version. Here’s the additional F# file for the project (which I’ll be providing in full at the end of the series): module CirclePackingFullFs open System.Numerics; // Use Descartes' theorem to calculate the radius/position // of the 4th circle // k4 = k1 + k2 + k3 +/- sqrt(k1k2 + k2k3 + k3k1)...
Read more →

February 10, 2012

To carry on from the last post in this series, today’s post is looking at a simple, initial attempt to pack circles into a space using F#. Rather than starting from the C# code in the previous post, I decided to look for a solution that makes better use of F#’s mathematical capabilities. I came across this simple Common LISP implementation, which creates a subset of a full Apollonian gasket. [Aside from the links in the previous post, this page may also provide additional insights into programmatic approaches for solving this problem.] Here’s my equivalent F# code: module CirclePackingFs...
Read more →

June 27, 2011

I’ve been planning to look at it for ages – and have certainly mentioned it before – but other things have kept on cropping up. Well last Thursday, on my train trip back from Wallisellen (the home of Microsoft Switzerland), I finally managed to take the plunge and start working with the Async CTP for Visual Studio 2010. I’d been in Wallisellen to attend an MSDN TechTalk presentation by Stephen Toub, Principal Architect on Microsoft’s Parallel Computing Platform team. I’ve followed Stephen via his blog – and the Parallel Programming with .NET blog – for a long time, and...
Read more →

November 22, 2010

Or perhaps the title should really be “why it’s really a good idea to avoid misusing mutable state when using F# Asynchronous Workflows”. Ultimately I wanted to share a brief (or not, we’ll see), cautionary tale about the dangers of shared state when implementing concurrent tasks. I’ve been using F# for some time, and have it fairly well drilled into my skull by this point that shared, mutable state is bad. And yet occasionally it somehow creeps in as an expedient way to solve certain issues: perhaps it’s just a lack of discipline on my part or the years...
Read more →

November 15, 2010

This handout is for the companion class to the one whose handout formed my last post. While that class was user-focused, this one, “CP322-2 - Integrate F# into Your C# or VB.NET Application for an 8x Performance Boost”, is more developer-focused and takes the hood off the implementation of the BrowsePhotosynth application. The code for this special version of the application – which imports synchronously via C# and synchronously/asynchronously via F# – is available here for download. Introduction This class takes a look at the implementation of BrowsePhotosynth for AutoCAD, the ADN Plugin of the Month from October 2010...
Read more →

November 10, 2010

A colleague set me a fun little geometry-related challenge a couple of days ago: to write C# and F# applications to make AutoCAD draw lines between a number of points spaced evenly around the circumference of a circle. Here’s the first C# version I wrote, which makes use of a function to collect the various points before indexing into the collection from a nested loop: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; using System; namespace CircleOfLines { public class Commands { public static Point3dCollection pointsOnCircle( Point3d center, double radius, int n ) { double alpha = Math.PI *...
Read more →

October 13, 2010

I had a very nice surprise in my inbox, this morning. Thorsten Meinecke, from GTB in Berlin, decided to convert the VB.NET code contained in the last post into an F# script and to share it with this blog’s readership. Thanks, Thorsten! :-) One thing about it being an F# script (typically stored in a .fsx file) is that it can be loaded and executed directly from the “F# Interactive” (FSI) component in Visual Studio without the need to build it into a project creating an executable. What’s also very nice is that the XAML defining the WPF dialog...
Read more →

October 08, 2010

I just thought I’d report back on a few changes made to the BrowsePhotosynth Plugin of the Month during the course of this week. The updated version has just been announced on Scott Sheppard’s blog and I thought I’d share some of the specific implementation details. The first one (in the 1.0.1 update) was a really interesting problem and I owe a big thanks both to Alberto Venturini for reporting it and to Marat Mirgaleev, from our DevTech team in Moscow, for helping test on a comparable OS. The problem was that on all the systems upon which Alberto...
Read more →

October 01, 2010

Many of you will have seen previous incarnations of this tool, during its development. It’s a little more complex than most of our other monthly plugins – mostly as it depends on a couple of external components – but the functionality should hopefully be simple enough to understand and use. I won’t go into great details here, but if you’re using AutoCAD 2011, give it a try by downloading the ZIP from the Autodesk Labs Plugin of the Month site and executing the contained installer package. From there you should be able to run the BROWSEPS command inside AutoCAD...
Read more →

August 31, 2010

The class catalogs for AU 2010 – for both the physical and virtual classes – have now been posted to the AU website: I have a few AU classes scheduled – thanks to any of you who took the time to vote for them. My first class is virtual… Getting to Know the AutoCAD® Plugins of the Month (CP212-1V) Tuesday November 30th, 6:00-7:00 am PST Tuesday November 30th, 11:00 am-12:00 pm PST The Autodesk Developer Network (ADN) team has been publishing "Plug-ins of the Month" on Autodesk Labs for over a year. Each of these plug-ins extends an Autodesk®...
Read more →

May 18, 2010

I’ve submitted three sessions for this year’s Autodesk University: Getting to know AutoCAD's Plugins of the Month (a 60-minute virtual class, session ID 1681) Synopsis: The Autodesk Developer Network (ADN) team has been publishing "Plugins of the Month" on Autodesk Labs for over a year. Each of these plugins extends an Autodesk products in a useful or interesting way, and is provided with full source code! Attend this session for an introduction to the various AutoCAD plugins that have been published (with a brief mention of those published for other products). We will take a detailed look at the...
Read more →

May 04, 2010

This one is a bit of an experiment: our first “fun” Plugin of the Month (fun in that it doesn’t serve a serious work-related purpose that I can think of :-). I’ve post earlier versions of the code to this blog, but thought I’d post and share the latest & greatest. Scott has kindly announced the plugin’s availability already over on It’s Alive in the Lab. This is our first Plugin on the Month written in F#, which means an additional DLL needs to be copied with the plugin itself. Other than that the application should work just as...
Read more →

April 30, 2010

In the previous posts in this series we introduced a command that downloaded and imported point clouds from Photosynth.net, we introduced a WinForms user interface on top of it and then replaced that UI with one implemented using WPF. As threatened last time, we’re now going to make some efficiency improvements in the original command implementation. In our previous implementation we were blindly asking for files, one after the other, and using failure to indicate when we’d reached the end. Which was fine, but it limited us in a few ways: we could not reliably parallelize this otherwise highly...
Read more →

March 12, 2010

Last week we looked at a preliminary version of this application that made use of an EntityJig to display a Spirograph as we provided the values needed to define it. While that was a good start, I decided it would be better to show additional graphics during the jig process, to give a clearer idea of the meaning of the information being requested from the user. I wanted, for instance, to show temporary circles indicating the radii of the outer and inner circles, mainly to make it clearer how the various parameters affect the display of the resultant Spirograph...
Read more →

March 08, 2010

This week I’m going to posting a few topics related to F#, as it feels as though I’ve been neglecting it, of late. And as this technology is going to hit the mainstream very soon – when Visual Studio 2010 ships – it seems all the more important to keep one’s F# skills honed. We’re going to start the week with an F# equivalent to the code shown in this previous post, where we go through and reflect on the commands exposed by an assembly in order to create corresponding demand-loading Registry keys automatically. We’ve shipped VB.NET and C#...
Read more →

March 05, 2010

After my initial fooling around with turning AutoCAD into a Spirograph using F#, I decided to come back to this and bolt a jig on the front to make the act of making these objects more visual and discoverable. The process was quite interesting – I’d created jigs from Python and Ruby, but not from F#, so this was a first for me. It’s also a multi-stage jig, which is fun: we acquire the outer radius of the pattern followed by the radius of the smaller circle and the distance of the pen from the smaller circle’s center. At...
Read more →

December 11, 2009

I’ve arrived at the end of my AU+East Asia tour, having spent the last 2 weeks in Las Vegas, San Francisco, Tokyo, Seoul and now Beijing. My blog is blocked by the Great Firewall of China, so while I can post this content via Typepad I can’t see the results (although I’m told I should be able to VPN into our Singapore office to bypass this restriction – I’ll give that a try, later on). Later today (and today is currently Friday December 11th in China :-) you should be able to gain access to the sessions I delivered...
Read more →

December 07, 2009

I’ve now crossed the international date line (giving up a big portion of my weekend, but that’s life) and landed in Tokyo. Tomorrow I head on to Seoul and then to Beijing for the end of the week. In many ways a change of pace from the week in Vegas, but in other ways it’s more of the same (fun, that is :-). In this previous post we looked at some code to retrieve and process RSS information from various blogs using an agent-based message passing architecture. The code wasn’t completely asynchronous or parallelised, though, as we fired off...
Read more →

November 29, 2009

For any Autodesk Developer Network members who have not already signed up for AUv, in the upcoming edition of our DevNews newsletter you’ll find a discount code allowing you to received a free Premier Pass for AU Virtual (normally worth $99). If you don’t know who in your organisation receives DevNews, please send us an email with your ADN number and we’ll get you the information. And if you do manage to attend, please do join one of my F# sessions (here are some other AutoCAD-related AUv sessions, and I know Jeremy’s also delivering one on Revit families).
Read more →

November 27, 2009

If you’re curious about the AU Virtual experience (perhaps you’ve signed up and are wondering what it’s going to be like, perhaps you’re thinking about signing up but would like to know what you’re getting into, or perhaps you have no intention whatsoever of signing up but just want to know what 13,000+ other people are going to be doing next week :-) then check out this video: And if you end up attending AUv, I’m sure there are plenty of virtual seats left in my F# class! :-)
Read more →