- 积分
- 105
- 明经币
- 个
- 注册时间
- 2013-10-11
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
照着书上敲的代码,但是"CommandClass"还有"CommandMethod"都是提示找不到,不知道是引用少了什么还是别的问题。
请大家看看。
谢谢。- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.Runtime;
- [assembly:CommandClass(typeof(Sample.Class1))]
- namespace ClassLibrary2
- {
- public class Class1
- {
- [CommandMethod("AddBlockDef")]
- public void AddblockDef()
- {
- Database db = HostApplicationServices.WorkingDatabase;
- BlockTableRecord btr = new BlockTableRecord();
- btr.Name = "bimcad";
- Line line = new Line(Point3d.Origin, new Point3d(10, 15, 0));
- Circle circle = new Circle(Point3d.Origin, Vector3d.ZAxis, 10);
- btr.AppendEntity(line);
- btr.AppendEntity(circle);
- AddBlockTableRecord(btr,db);
- }
- public ObjectId AddBlockTableRecord(BlockTableRecord btr, Database db)
- {
- ObjectId id = new ObjectId();
- using(Transaction transaction=db.TransactionManager.StartTransaction())
- {
- BlockTable bt = transaction.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
- id = bt.Add(btr);
- transaction.AddNewlyCreatedDBObject(btr, true);
- transaction.Commit();
- }
- return id;
- }
- }
- }
|
|