- ar r1 = Env.Editor.GetString("\n选择要查找的文字");
- if (r1.Status != PromptStatus.OK)
- return;
- var str = r1.StringResult;
- using var tr = new DBTrans();
- HashSet<ObjectId> layerIdSet = new();
- foreach (var btr in tr.BlockTable.GetRecords())
- {
- foreach (var ent in btr.GetEntities<Entity>())
- {
- if(ent is DBText ||ent is MText)
- {
- layerIdSet.Add(ent.LayerId);
- }
- else if(ent is BlockReference brf)
- {
- foreach (var att in brf.GetAttributes())
- {
- layerIdSet.Add(att.LayerId);
- }
- }
- }
- }
- foreach (var ltr in layerIdSet.GetObject<LayerTableRecord>(OpenMode.ForWrite))
- {
- if(!ltr.IsOff)
- ltr.IsOff = true;
- }
因为没说什么语言,所以用了c# powered by ifox
|