c#autocad set ucs z axis

时间:2016-01-29 21:45:54

标签: c# autocad

我的google-fu在设置autocad ucs z轴方面很弱。我已经在网上看到许多用于定义ucs的例子,尽管没有设置z轴的例子。我可以通过命令行输入手动设置z轴' ucs'然后' za'并选取2个点来定义z轴。

我试过这个: Align the UCS to an entity

因为我需要它不起作用。我也试过修改这个,但我显然缺少一些C#的知识来做到这一点。任何帮助表示赞赏。

由于

1 个答案:

答案 0 :(得分:1)

这是一种扩展方法:

public static class EditorExtension
{
    public static void SetZAxisUcs (this Editor ed, Point3d basePoint, Point3d positiveZaxisPoint)
    {
        Plane plane = new Plane(basePoint, basePoint.GetVectorTo(positiveZaxisPoint));
        Matrix3d ucs = Matrix3d.PlaneToWorld(plane);
        ed.CurrentUserCoordinateSystem = ucs;
    }
}