马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Identifying the boundary through API By Virupaksha Aithal
AutoCAD 2011 introduced a new API to identify the boundary objects for a provided point. Below code shows the use of the same API in .NET. The equivalent ObjectARX API is “acedTraceBoundary”.
Note, only visible entities are considered while identifying the boundary objects.
- [CommandMethod("BoundaryTest")]
- public static void BoundaryTest()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- PromptPointOptions ptOptions =
- new PromptPointOptions("Select point ");
- ptOptions.AllowNone = false;
- PromptPointResult ptResult = ed.GetPoint(ptOptions);
- if (ptResult.Status != PromptStatus.OK)
- return;
- DBObjectCollection collection =
- ed.TraceBoundary(ptResult.Value, true);
- using (Transaction Tx =
- db.TransactionManager.StartTransaction())
- {
- ObjectId ModelSpaceId =
- SymbolUtilityServices.GetBlockModelSpaceId(db);
- BlockTableRecord model = Tx.GetObject(ModelSpaceId,
- OpenMode.ForWrite) as BlockTableRecord;
- foreach (DBObject obj in collection)
- {
- Entity ent = obj as Entity;
- if (ent != null)
- {
- //make the color as red.
- ent.ColorIndex = 1;
- model.AppendEntity(ent);
- Tx.AddNewlyCreatedDBObject(ent, true);
- }
- }
- Tx.Commit();
- }
- }
|