本帖最后由 chpmould 于 2010-12-4 12:23 编辑
手册我看了N边,但还是没有明白,请帮修改以下程序错在那里- [CommandMethod("Test")]
- public static void DText()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- PromptSelectionOptions optSel = new PromptSelectionOptions();
- optSel.MessageForAdding = "选择对象";
- PromptSelectionResult resSel = ed.GetSelection(optSel);
- SelectionSet sSet = resSel.Value;
- ObjectId[] ids = sSet.GetObjectIds();
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
- AlignedDimension Dim = new AlignedDimension();
- Dim.DimensionStyle = db.Dimstyle;
- foreach (ObjectId sSetEntId in ids)
- {
- Dim.DimensionText = "<>(长度)";
- }
- btr.AppendEntity(Dim);
- trans.AddNewlyCreatedDBObject(Dim, true);
- trans.Commit();
- }
- }
|