2017-08-02 90 views
0

我想將UCS移動到特定點,然後根據剛剛移動的UCS獲取實體座標(在本例中爲圓形)作爲其基點。從代碼獲得的座標結果不正確(X3.0,Y5.5,Z0),這是沒有意義的。它們應該是(X2.5,Y0.0,Z0.0)。 我的代碼運行後,我可以在AutoCad中手動檢查座標,並且是正確的。不知道問題是什麼。任何幫助將不勝感激。獲取實體基於其UCS作爲基點的座標

private static void UcsBaseCoords(Circle circle, Point3d newBasePoint) 
    { 
     var acDoc = Active.Document; 

     CoordinateSystem3d coordSystem = new CoordinateSystem3d(newBasePoint, new Vector3d(0, -1, 0),new Vector3d(1, 0, 0)); 

     CoordinateSystem3d cosy = acDoc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d; 

     var ecs = Matrix3d.AlignCoordinateSystem(cosy.Origin, cosy.Xaxis, cosy.Yaxis, cosy.Zaxis, coordSystem.Origin, coordSystem.Xaxis, coordSystem.Yaxis, coordSystem.Zaxis); 

     acDoc.Editor.CurrentUserCoordinateSystem = ecs; 

     acDoc.Editor.UpdateTiledViewportsInDatabase(); 

     var coodrsBasedOnUcs = circle.Center.TransformBy(ecs); 
     acDoc.Editor.WriteMessage(String.Format("X{0}, Y{1}, Z{2}", coodrsBasedOnUcs.X, coodrsBasedOnUcs.Y, coodrsBasedOnUcs.Z)); 
    } 

這是我的DWG在我運行我的程序之前。 enter image description here

這是我的程序運行後,它是正確的。 (X2.5,Y0.0,Z0.0) enter image description here

回答