本帖最后由 d1742647821 于 2023-5-30 23:41 编辑
规整圆弧 powered by IFoxCad version v0.7
视频举例规整为25的倍数
- [CommandMethod(nameof(CS5),CommandFlags.UsePickSet)]
- public static void CS5()
- {
- PromptSelectionOptions pso = new() { MessageForAdding = "\n选择圆或圆弧", RejectObjectsOnLockedLayers = true };
- var sf = OpFilter.Build(e => e.Dxf(0) == "ARC" | e.Dxf(0) == "CIRCLE");
- var r1 = Env.Editor.GetSelection(pso, sf);
- if (r1.Status != PromptStatus.OK)
- return;
- var r2 = Env.Editor.GetInteger("\n选择要取整的数值");
- if (r2.Status != PromptStatus.OK)
- return;
- var sr = r2.Value;
- using var tr = new DBTrans();
- foreach (var id in r1.Value.GetObjectIds())
- {
- var dbo = tr.GetObject(id, OpenMode.ForWrite);
- if (dbo is Circle c)
- {
- var a = Math.Round(c.Radius / sr) * sr;
- c.Radius = a == 0 ? sr : a;
- }
- else if (dbo is Arc arc)
- {
- var a = Math.Round(arc.Radius / sr) * sr;
- arc.Radius = a == 0 ? sr : a;
- }
- }
- }
|