|
很早前的F#处女作了。
申请核心会员 转载请注明出处
#!fsharp
// 使用 F# 缩略语法
#light
// 声明独有的命令空间和类
module FsTest.DrawLine
// 指定包含文件夹
#I @"D:\\AutoCAD 2008"
// 引用托管
#r "acdbmgd.dll"
#r "acmgd.dll"
open Autodesk.AutoCAD.Runtime
open Autodesk.AutoCAD.ApplicationServices
open Autodesk.AutoCAD.DatabaseServices
open Autodesk.AutoCAD.Geometry
// 声明命令
[<commandmethod (?DRAWLINE?)>]
let DrawLine () =
let line = new Line(new Point3d(0.0, 0.0, 0.0), new Point3d(3333.0, 3333.0, 0.0))
let db = Application.DocumentManager.MdiActiveDocument.Database
use trans = db.TransactionManager.StartTransaction()
let bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead):?> BlockTable
let btr = trans.GetObject(bt.[BlockTableRecord.ModelSpace], OpenMode.ForWrite):?> BlockTableRecord
btr.AppendEntity(line) |> ignore
trans.AddNewlyCreatedDBObject(line, true)
trans.Commit()
--------------------------------------------------------------------------------
#!csharp
// 下面是才鸟老大在 DotNetARX 帮助文件中, 第一页 Geting Started 的第一段 C# 示例.
// 对比一下还是蛮像的嘛~_~
Line line = new Line(new Point3d(0.0, 0.0, 0.0), new Point3d(3333.0, 3333.0, 0.0));
Database db = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);
btr.AppendEntity(line);
trans.AddNewlyCreatedDBObject(line, true);
trans.Commit();
} |
|