- 积分
- 949
- 明经币
- 个
- 注册时间
- 2014-12-1
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
功能:根据已知的坐标,给块参照加颜色,但语句中的Ent一直是空,而ID是有值的
private void getBlkForPt(Point3d dataBasePt)
{
Document doc = app.DocumentManager.MdiActiveDocument;
BlockReference Blk = null;
using (Transaction trans = doc.TransactionManager.StartTransaction())
{
BlockTable BlkTab = (BlockTable)trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead,true) as BlockTable;
foreach (ObjectId ID in BlkTab)
{
Entity Ent = trans.GetObject(ID,OpenMode.ForRead,true) as Entity;
if (Ent != null)
{
if (Ent is BlockReference)
{
Blk = (BlockReference)Ent;
Point3d pt = Blk.Position;
if (pt.DistanceTo(dataBasePt) <= 1)
{
Blk.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 0);
}
}
}
}
}
}
|
|