From f83e45e12aba324b9256ca23c1ad58ddf1febfa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Tue, 3 Sep 2024 07:54:02 +0000 Subject: [PATCH] =?UTF-8?q?!3059=20=E4=BC=98=E5=8C=96:=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E5=A4=9A=E6=AE=B5=E7=BA=BF=E5=8A=9F=E8=83=BD=E6=A0=8F=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=AE=80=E5=8C=96=E5=A4=9A=E6=AE=B5=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../testEntity/TestPolyline2PointsPolyline.ts | 29 +++++++++++-------- src/Editor/DbClick/DBClickPolyline.ts | 6 +++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Add-on/testEntity/TestPolyline2PointsPolyline.ts b/src/Add-on/testEntity/TestPolyline2PointsPolyline.ts index 395b3c463..07a2cc372 100644 --- a/src/Add-on/testEntity/TestPolyline2PointsPolyline.ts +++ b/src/Add-on/testEntity/TestPolyline2PointsPolyline.ts @@ -28,20 +28,25 @@ export class Command_SimplifyPolyline implements Command if (ssRes.Status !== PromptStatus.OK) return; let pls = ssRes.SelectSet.SelectEntityList as Polyline[]; - let count = 0; - for (let pl of pls) + SimplifyPolyline(pls); + } +} + +export function SimplifyPolyline(pls: Polyline[]) +{ + let count = 0; + for (let pl of pls) + { + let npl = SmartPolylineSimply2Polyline(pl); + if (npl && npl.EndParam < pl.EndParam) { - let npl = SmartPolylineSimply2Polyline(pl); - if (npl && npl.EndParam < pl.EndParam) - { - pl.Erase(); - app.Database.ModelSpace.Append(npl); + pl.Erase(); + app.Database.ModelSpace.Append(npl); - Log(`简化成功!${pl.EndParam} -> ${npl.EndParam}`); - count++; - } + Log(`简化成功!${pl.EndParam} -> ${npl.EndParam}`); + count++; } - - Log(`成功简化了${count}条多段线!`); } + + Log(`成功简化了${count}条多段线!`); } diff --git a/src/Editor/DbClick/DBClickPolyline.ts b/src/Editor/DbClick/DBClickPolyline.ts index 874ddbf41..56a9c86a9 100644 --- a/src/Editor/DbClick/DBClickPolyline.ts +++ b/src/Editor/DbClick/DBClickPolyline.ts @@ -1,3 +1,4 @@ +import { SimplifyPolyline } from "../../Add-on/testEntity/TestPolyline2PointsPolyline"; import { app } from "../../ApplicationServices/Application"; import { arraySortByNumber } from "../../Common/ArrayExt"; import { curveLinkGroup } from "../../Common/CurveUtils"; @@ -30,7 +31,7 @@ export class DBClickPolyline extends Singleton { key: "J", msg: "合并" }, { key: "E", msg: "编辑顶点" }, // { key: "F", msg: "拟合" }, - // { key: "S", msg: "样条曲线" }, + { key: "S", msg: "简化多段线" }, { key: "D", msg: "非曲线化" }, { key: "R", msg: "反转" }, { key: "U", msg: "放弃" } @@ -76,6 +77,9 @@ export class DBClickPolyline extends Singleton execStatus = await this.EditorVertex(); JigUtils.Destroy(); break; + case "S": //简化多段线 + SimplifyPolyline([pl]); + return; case "D": //非曲线化 this.TransfromNonCurve(); break;