I was thinking about coding one in F# ... but real work and sleep keep getting in the way ...
//kdub
Sorry to dredge up old posts, but I was bored over lunch. I don't imagine this will run much different than the C# versions.
module Acad
open System
open Autodesk.AutoCAD.ApplicationServices
open Autodesk.AutoCAD.DatabaseServices
open Autodesk.AutoCAD.Geometry
open Autodesk.AutoCAD.Runtime
let GetActiveDoc () =
Application.DocumentManager.MdiActiveDocument
let GetPoints () =
let db = GetActiveDoc().Database
use trans = db.TransactionManager.StartTransaction()
let blocks = trans.GetObject(db.BlockTableId, OpenMode.ForRead) :?> BlockTable
let modelSpace = trans.GetObject(blocks.[BlockTableRecord.ModelSpace], OpenMode.ForWrite) :?> BlockTableRecord
for id in modelSpace do
let dbObj = trans.GetObject(id, OpenMode.ForWrite)
match dbObj with
| :? DBPoint as pnt->
let circ = new Circle(pnt.Position, Vector3d.ZAxis, 4.0)
modelSpace.AppendEntity(circ) |> ignore
trans.AddNewlyCreatedDBObject(circ, true)
pnt.Erase()
| _ -> ()
trans.Commit()
let Timer f =
let timer = new System.Diagnostics.Stopwatch()
timer.Start()
f()
timer.Stop()
timer.Elapsed.TotalSeconds
let Print x =
GetActiveDoc().Editor.WriteMessage("\n" + x.ToString())
[<CommandMethod("pts")>]
let pts () =
Timer GetPoints
|> Print
0.4217323