既然没要求语言,那就发个c#的
powered by ifox
- [CommandMethod(nameof(Test1), CommandFlags.UsePickSet)]
- public static void Test1()
- {
- var sf = OpFilter.Build(e => e.Dxf(0) == "MTEXT");
- PromptSelectionOptions pso = new PromptSelectionOptions() { MessageForAdding = "\n选择要修改颜色的多行文字", RejectObjectsOnLockedLayers = true };
- var r1 = Env.Editor.GetSelection(pso, sf);
- if (r1.Status != PromptStatus.OK)
- return;
- using var tr = new DBTrans();
- var mtList1 = r1.Value.GetEntities<MText>(OpenMode.ForWrite);
- if (!mtList1.Any())
- return;
- var r2 = Env.Editor.GetInteger("\n输入颜色号");
- if (r2.Status != PromptStatus.OK)
- return;
- var colorIndex = Math.Abs(r2.Value) % 257;
- foreach (var mt in mtList1)
- {
- mt.Contents = mt.Text;
- mt.ColorIndex = colorIndex;
- }
- }
|