Hi,
With plain .NET, you can use the following extension methods.
Dim point1DCS() As Double = AcadApp.ActiveDocument.Utility.TranslateCoordinates(pt1, AcCoordinateSystem.acWorld, AcCoordinateSystem.acDisplayDCS, False)
would be:
Point3d point1DCS = pt1.TransformBy(ed.WCS2DCS());
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using System;
namespace AutoCadUtilsLibrary
{
public static class Extension
{
public static Matrix3d EyeToWorld(this AbstractViewTableRecord view)
{
if (view == null)
throw new ArgumentNullException("view");
return
Matrix3d.Rotation(-view.ViewTwist, view.ViewDirection, view.Target) *
Matrix3d.Displacement(view.Target.GetAsVector()) *
Matrix3d.PlaneToWorld(view.ViewDirection);
}
public static Matrix3d WorldToEye(this AbstractViewTableRecord view)
{
if (view == null)
throw new ArgumentNullException("view");
return
Matrix3d.WorldToPlane(view.ViewDirection) *
Matrix3d.Displacement(view.Target.GetAsVector().Negate()) *
Matrix3d.Rotation(view.ViewTwist, view.ViewDirection, view.Target);
}
public static Matrix3d DCS2WCS(this Editor ed)
{
if (ed == null)
throw new ArgumentNullException("ed");
using (ViewTableRecord view = ed.GetCurrentView())
{
return view.EyeToWorld();
}
}
public static Matrix3d WCS2DCS(this Editor ed)
{
if (ed == null)
throw new ArgumentNullException("ed");
using (ViewTableRecord view = ed.GetCurrentView())
{
return view.WorldToEye();
}
}
}
}