第一个c#练习的程序遍历块获取块内图元的外框
public void PickDemo()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult per = ed.GetEntity("选择块");
if (per.Status == PromptStatus.OK)
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
ResultBuffer result = new ResultBuffer();
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockReference br = (BlockReference)per.ObjectId.GetObject(OpenMode.ForRead);
string blkname = br.Name;
ed.WriteMessage("\nBlock Name: (" + blkname + ").");
ObjectId blockRecordId = bt;
BlockTableRecord blockRecord = (BlockTableRecord)blockRecordId.GetObject(OpenMode.ForRead);
Extents3d tmpExtents3D = new Extents3d();
foreach (ObjectId entID in blockRecord)
{
Entity entity = (Entity)trans.GetObject(entID, OpenMode.ForRead);
Extents3d tmp = entity.GeometricExtents;
tmpExtents3D.AddExtents(tmp);
}
Point3d maxpt = tmpExtents3D.MaxPoint;
Point3d minpt = tmpExtents3D.MinPoint;
result.Add(new TypedValue((int)LispDataType.Point3d, minpt));
result.Add(new TypedValue((int)LispDataType.Point3d, maxpt));
trans.Commit();
//return result;
}
}
} 最好能做一个非块的外轮廓线的生成 很不错的做法 感谢大神的分享~ 最大边界要能识别 样条曲线 多线段 直线 圆弧 块 还能设置容差 就完美了!! 估计这个很难做到!
页:
[1]