马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
How to sync UCS with current view like command UCS+VBy Philippe Leefsma
Here is how to achieve the same functionality than command UCS+V using .Net API:
////////////////////////////////////////////////////////////////// // Use: Sync UCS with Current view like command UCS V // Author: Philippe Leefsma, September 2011 ////////////////////////////////////////////////////////////////// [CommandMethod("UcsV" public static void UcsV() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; Autodesk.AutoCAD.GraphicsSystem.Manager mng = doc.GraphicsManager; short cvport = (short)Application.GetSystemVariable("CVPORT"); Autodesk.AutoCAD.GraphicsSystem.View view = mng.GetGsView(cvport, true); Vector3d direction = (view.Target - view.Position); direction = direction.MultiplyBy(1 / direction.Length); Vector3d upVector = view.UpVector; upVector = upVector.MultiplyBy(1 / upVector.Length); Vector3d xAxis = direction.CrossProduct(upVector); Matrix3d ucs = Matrix3d.AlignCoordinateSystem( new Point3d(0, 0, 0), Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis, new Point3d(0, 0, 0), xAxis, upVector, direction); ed.CurrentUserCoordinateSystem = ucs; }
|