- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2009-11-1 17:22:00
|
显示全部楼层
以前写的代码,另外,Vector3D这个参数设置为Vector3d.ZAxis没问题,但只能在2010版本用SetFrom- [CommandMethod("ts3")]
- public static void tt3()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Wipeout w = new Wipeout();
- w.Orientation = new CoordinateSystem3d(new Point3d(100, 100, 0), Vector3d.XAxis, Vector3d.YAxis);
- List<Point3d> pnts = new List<Point3d>();
- pnts.Add(new Point3d(100, 100, 0));
- pnts.Add(new Point3d(800, 100, 0));
- pnts.Add(new Point3d(800, 600, 0));
- pnts.Add(new Point3d(100, 600, 0));
- pnts.Add(new Point3d(100, 100, 0));
- Matrix3d mat = w.PixelToModelTransform.Inverse();
- Point2dCollection vers = new Point2dCollection();
- for (int i = 0; i < pnts.Count; i++)
- {
- pnts[i] = pnts[i].TransformBy(mat);
- vers.Add(pnts[i].Convert2d(new Plane()));
- }
- w.SetClipBoundary(ClipBoundaryType.Poly, vers);
- BlockTableRecord btr = (BlockTableRecord)db.CurrentSpaceId.GetObject(OpenMode.ForWrite);
- btr.AppendEntity(w);
- tr.AddNewlyCreatedDBObject(w, true);
- tr.Commit();
- }
- }
|
|