- 积分
- 656
- 明经币
- 个
- 注册时间
- 2010-8-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2012-8-22 12:23:45
|
显示全部楼层
我自己研究出来了,这个命令是用3点画MLINE,第一点第二点的距离是MLINE的SCALE,第一点第二点的中点是MLINE的起点,第三点是MLINE的终点。下面是代码
[CommandMethod("lp")]
public static void Multline()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointResult ppr1 = doc.Editor.GetPoint("\nspecial start point1");
PromptPointResult ppr2 = doc.Editor.GetPoint("\nspecial start point2");
Point3d pt1 = new Point3d(((ppr1.Value.X + ppr2.Value.X) / 2), ((ppr1.Value.Y + ppr2.Value.Y) / 2), 0);
PromptPointResult ppr3 = doc.Editor.GetPoint("\nspecial end point");
Point3d pt2 = ppr3.Value;
double l = Math.Sqrt(Math.Pow((ppr2.Value.X - ppr1.Value.X), 2) + Math.Pow((ppr1.Value.Y - ppr2.Value.Y), 2));
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
Mline ml = new Mline();
ml.SetDatabaseDefaults();
DBDictionary MlineStyleDic = (DBDictionary)trans.GetObject(db.MLStyleDictionaryId, OpenMode.ForWrite);
MlineStyle ms = new MlineStyle();
ms = (MlineStyle)trans.GetObject(MlineStyleDic.GetAt("STANDARD"), OpenMode.ForRead);
ml.Style = ms.ObjectId;
ml.Scale = l;
ml.Justification = MlineJustification.Zero;
Vector3d vec = new Vector3d(0,0,1);
ml.Normal = vec;
ml.AppendSegment(pt1);
ml.AppendSegment(pt2);
btr.AppendEntity(ml);
trans.AddNewlyCreatedDBObject(ml, true);
trans.Commit();
}
} |
|