« Implementing your own AutoCAD color combobox control using .NET | Main | Embedding AutoCAD 2009 in a standalone dialog »

March 25, 2008

Initialization code in your F# AutoCAD application

Back from a nice long weekend, although I spent most of it sick with a cold. I find this increasingly the way with me: I fend off illness for months at a time (probably through stress, truth be told) but then I get a few days off and wham. A shame, as we had a huge dump of snow over the weekend... we get white Christmases here every five years or so, but it's really uncommon to get a white Easter.

I had a very interesting question come in by email from 冷血儿, who wanted to get the technique shown in this post working in his F# application.

Here's the F# code I managed to put together after consulting hubFS, in particular:

#light


namespace MyNamespace


open Autodesk.AutoCAD.Runtime

open Autodesk.AutoCAD.ApplicationServices


type InitTest() =

  class

    let ed =

      Application.DocumentManager.MdiActiveDocument.Editor

    interface IExtensionApplication with

      member x.Initialize() =

        ed.WriteMessage

          ("\nInitializing - do something useful.")

      member x.Terminate() =

        printfn "\nCleaning up..."

  end

end


module MyApplication =

  let ed =

    Application.DocumentManager.MdiActiveDocument.Editor

  [<CommandMethod("TST")>]

  let f () =

    ed.WriteMessage("\nThis is the TST command.")

  [<assembly: ExtensionApplication(type InitTest)>]

  do

    ed.WriteMessage("\nModule do")

Here's what happens when we load our module and run the TST command:

Command: NETLOAD

Module do

Initializing - do something useful.

Command: TST

This is the TST command.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83452464869e200e551711a2c8833

Listed below are links to weblogs that reference Initialization code in your F# AutoCAD application:

» F# and ArcGIS/ArcObjects from Don Syme's WebLog on F# and Other Research Projects
Ray Vernagus has posted an introduction to using F# with ArcGIS through ArcObjects . One of the things [Read More]

Comments

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

RSS Feed

Search