马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[C#] 纯文本查看 复制代码
[CommandMethod("Remove3DVertex")]
static public void RemoveVertex()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction oTr =
db.TransactionManager.StartTransaction())
{
ObjectIdCollection ids = new ObjectIdCollection();
PromptEntityOptions options =
new PromptEntityOptions("\nPick a 3DPolyline:");
options.SetRejectMessage("Select 3DPolyline only" + "\n");
options.AddAllowedClass(typeof(Polyline3d), true);
PromptEntityResult result = ed.GetEntity(options);
if (result.Status != PromptStatus.OK)
return;
Polyline3d oEnt = oTr.GetObject(result.ObjectId,
OpenMode.ForRead) as Polyline3d;
foreach (ObjectId oVtId in oEnt)
{
PolylineVertex3d oVt = oTr.GetObject(oVtId,
OpenMode.ForRead) as PolylineVertex3d;
PromptKeywordOptions oPko =
new PromptKeywordOptions("\nWant to remove vertex at "
+ oVt.Position.ToString() + "?");
oPko.AllowNone = false;
oPko.Keywords.Add("Yes");
oPko.Keywords.Add("No");
oPko.Keywords.Default = "No";
PromptResult oPkr = ed.GetKeywords(oPko);
if (oPkr.Status == PromptStatus.OK
&& oPkr.StringResult == "Yes")
{
ids.Add(oVtId);
}
}
foreach (ObjectId oVtId in ids)
{
PolylineVertex3d oVt = oTr.GetObject(oVtId,
OpenMode.ForWrite) as PolylineVertex3d;
oVt.Erase();
}
if (ids.Count != 0)
{
oEnt.UpgradeOpen();
oEnt.RecordGraphicsModified(true);
}
oTr.Commit();
}
} |