- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2009-8-17 23:35:00
|
显示全部楼层
发几个使用的例子:)
1、Ge创建圆弧(中点、起点,圆心)
同理实现起点,弧上点、中点,GeArc有相应的构筑函数- [CommandMethod("CCicByDb")]
- public static void CCicByDb()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Point3d p1 = new Point3d(10,0,10);
- Point3d p2 = new Point3d(0,200,0);
- Plane plane = new Plane(p1, Point3d.Origin, p2);
- Matrix3d mat = Matrix3d.WorldToPlane(plane);
- p1 = p1.TransformBy(mat);
- p2 = p2.TransformBy(mat);
-
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Curve arc = new Arc(Point3d.Origin, p1.GetAsVector().Length, p1.GetAsVector().AngleOnPlane(new Plane()), p2.GetAsVector().AngleOnPlane(new Plane()));
- arc.TransformBy(mat.Inverse());
- BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
- btr.AppendEntity(arc);
- tr.AddNewlyCreatedDBObject(arc,true);
- tr.Commit();
- }
- }
- [CommandMethod("CCirByGe")]
- public static void CCirByGe()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Vector3d startvec = new Vector3d(10, 0, 10);
- Vector3d endvec = new Vector3d(0, 200, 0);
- endvec = endvec.GetNormal() * startvec.Length;
- Vector3d othervec = startvec + endvec;
- othervec = othervec.GetNormal() * startvec.Length;
- CircularArc3d ca3d = new CircularArc3d(Point3d.Origin + startvec, Point3d.Origin + othervec, Point3d.Origin + endvec);
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Curve arc = ConvertCurve.ToArc(ca3d);
- BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
- btr.AppendEntity(arc);
- tr.AddNewlyCreatedDBObject(arc, true);
- tr.Commit();
- }
- }
|
|