C#如何遍历块内图元
如题C#如何遍历块内图元,以达到修改块元素属性的目的!块遍历,与图层内实体遍历等都是collection遍历,基本上都使用foreach。
PromptEntityResult blockSelected = AutoCadDatabaseOperate.m_ed.GetEntity("请选择一个块参考");
using Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction();
BlockReference blockReference = trans.GetObject(blockSelected.ObjectId, OpenMode.ForWrite) as BlockReference;
BlockTableRecord btr = trans.GetObject(blockReference.BlockTableRecord, OpenMode.ForWrite) as BlockTableRecord;
foreach (var id in btr)
{
Entity ent = trans.GetObject(id, OpenMode.ForWrite) as Entity;
if (ent is null)
{
continue;
}
else
{
ent.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 3);
}
}
trans.Commit();
好的,非常感谢 本帖最后由 寒风 于 2020-7-18 14:19 编辑
cairunbin 发表于 2020-7-18 08:19
块遍历,与图层内实体遍历等都是collection遍历,基本上都使用foreach。
PromptEntityResult blockSe ...
遍历动态块图元,如何处理呢
搞错了,已解决,谢谢!
http://bbs.mjtd.com/thread-180964-1-1.html
页:
[1]