首页 > 代码库 > cad.net创建wipeout仅支持2008及以后版本
cad.net创建wipeout仅支持2008及以后版本
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
namespace WipeoutApplication
{
public class Commands
{
[CommandMethod("CW")]
public void CreateWipeout()
{
Document doc =
Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr =
db.TransactionManager.StartTransaction();
using (tr)
{
BlockTable bt =
(BlockTable)tr.GetObject(
db.BlockTableId,
OpenMode.ForRead,
false
);
BlockTableRecord btr =
(BlockTableRecord)tr.GetObject(
bt[BlockTableRecord.ModelSpace],
OpenMode.ForWrite,
false
);
Point2dCollection pts =
new Point2dCollection(5);
pts.Add(new Point2d(0.0, 0.0));
pts.Add(new Point2d(100.0, 0.0));
pts.Add(new Point2d(100.0, 100.0));
pts.Add(new Point2d(0.0, 100.0));
pts.Add(new Point2d(0.0, 0.0));
Wipeout wo = new Wipeout();
wo.SetDatabaseDefaults(db);
wo.SetFrom(pts, new Vector3d(0.0, 0.0, 0.1));
btr.AppendEntity(wo);
tr.AddNewlyCreatedDBObject(wo, true);
tr.Commit();
}
}
}
}