/// <summary> /// 提示用户拾取点集合 /// </summary> /// <returns>点集合</returns> public static Point3dCollection GetPoints() { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Point3dCollection p3d = new Point3dCollection(); string message = "\n请选择点"; try { while (true) { PromptPointResult pt = ed.GetPoint(message); if (pt.Status == PromptStatus.OK) { message = "\n请选择下一点"; p3d.Add(pt.Value); } else if (pt.Status == PromptStatus.Cancel) { break; } } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ShowMsgOperation.Alert(ex.ToString()); } return(p3d); }
/// <summary> /// 选取插入的基点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; SelectObjOperation.SelectCADWindows(); PromptPointResult pt = ed.GetPoint("\n请选择点"); if (pt.Status == PromptStatus.OK) { bPoint = (Point3d)pt.Value; ShowMsgOperation.Message("您选择了点:" + bPoint.X + "," + bPoint.Y + "\n"); } else { ShowMsgOperation.Message("未选择点,默认为原点"); } lblPointValue.Text = bPoint.X.ToString() + " , " + bPoint.Y.ToString(); this.Focus(); }
/// <summary> /// 改变圆的图层为“PSWCAD” /// </summary> /// <param name="ent"></param> private void change(Entity ent) { Database db = Application.DocumentManager.MdiActiveDocument.Database; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; using (Transaction transaction = db.TransactionManager.StartTransaction()) { Entity en = transaction.GetObject(ent.Id, OpenMode.ForWrite) as Entity; LayerTable lt = transaction.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable; LayerTableRecord ltr = transaction.GetObject(db.Clayer, OpenMode.ForRead) as LayerTableRecord; if (!lt.Has("PSWCAD")) { ShowMsgOperation.Alert("没有PSWCAD图层!"); return; } ent.Layer = "PSWCAD"; transaction.Commit(); } }
/// <summary> /// 自动绘制梁 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click_1(object sender, EventArgs e) { try { //创建矩形 double height = Convert.ToDouble(nudBeamHeight.Value); double width = Convert.ToDouble(nudBeamTopHeight.Value); Rectangle3d rec3d = CreateEntityOperation.CreateRectangle(height, width, bPoint); MyRectangle rect = new MyRectangle(rec3d); //将矩形添加到数据库中 Database db = DBOperation.GetDocumentDatabase(); //DBOperation.AddToModelSpace(rect.CreateRect(), db); DBOperation.AddToModelSpace(CreatePolyLineOfRectangle(), db); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ShowMsgOperation.Message(ex.Data + "\n" + ex.Source + "\n" + ex.TargetSite + "\n" + ex.ToString()); } }