Code Red > .NET
Command "_.TRIM"
(1/1)
Pepe:
Learning C#.NET for Autocad.
A simple exercise to deal with built-in commands of Autocad: trim a bunch of lines by a fence. I get an exemption at "ed.command("_.TRIM")", and I can't find anywhere what I'm doing wrong.
Any advices and ideas?
--- Code: ---[CommandMethod("TST2")]
public void Tst2()
{
Document doc = AcAp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Line obj;
PromptEntityOptions peo = new PromptEntityOptions("\nSelect edge: ");
peo.SetRejectMessage("\nSelect a LINE for edge...");
peo.AddAllowedClass(typeof(Line), true);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
obj = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Line;
obj.Highlight();
tr.Commit();
}
// Prompt for the start point
PromptPointOptions ppt = new PromptPointOptions("\nFirst point of the edge: ");
PromptPointResult pep = doc.Editor.GetPoint(ppt);
Point3d pini = pep.Value;
if (pep.Status == PromptStatus.Cancel) return;
// Prompt for the end point
ppt.Message = "\nSecond point of the edge: ";
ppt.UseBasePoint = true;
ppt.BasePoint = pini;
pep = doc.Editor.GetPoint(ppt);
Point3d pfin = pep.Value;
if (pep.Status == PromptStatus.Cancel) return;
ed.Command("_.TRIM", obj, "_F", pini, pfin );
obj.Unhighlight();
}
--- End code ---
Navigation
[0] Message Index
Go to full version