This project has moved and is read-only. For the latest updates, please go here.

A small query

May 5, 2013 at 4:16 AM

Does this library supports OCS to WCS conversion too?
May 6, 2013 at 1:32 AM
Edited May 6, 2013 at 4:16 AM
You can transform any Vector3 from OCS to WCS and viceversa, if that is what you need. Check the methods:
public static Vector3 Transform(Vector3 point, Vector3 zAxis, CoordinateSystem from, CoordinateSystem to)
public static List<Vector3> Transform(List<Vector3> points, Vector3 zAxis, CoordinateSystem from, CoordinateSystem to)
in the MathHelper class. They use the implementation of the arbitrary axis algorithm as defined in the dxf documentation. You can also check the method:
public static Matrix3 ArbitraryAxis(Vector3 zAxis)
May 6, 2013 at 12:03 PM
Hi Daniel

Thanks for your quick reply. Is there any other global variables which need to be set apart from passing the required variables into the function? Because, I did not get the converted result when I tested with a small example. Can u share with a sample code showing how to use this particular function?

May 6, 2013 at 5:20 PM
Take a look at this sample code. It creates a light weight polyline which vertexes are defined in OCS and at the end it converts them to WCS coordinates. You do not need to set any global variable to use those methods, just to pass the required information. You can run the code and load the generated dxf into AutoCad, if you compare the values of the coordinates of the converted vertexes (vertexesWCS list), they should be the same if you id the polyline vertexes in AutoCad.
// vertexes of the light weight polyline, they are defined in OCS (Object Coordinate System)
LwPolylineVertex v1 = new LwPolylineVertex(1, -5);
LwPolylineVertex v2 = new LwPolylineVertex(-3, 2);
LwPolylineVertex v3 = new LwPolylineVertex(8, 15);

LwPolyline lwp = new LwPolyline(new List<LwPolylineVertex> {v1, v2, v3});
// the normal will define the plane where the lwpolyline is defined
lwp.Normal = new Vector3(1, 1, 0);
// the entity elevation defines the z vector of the vertexes along the entity normal
lwp.Elevation = 2.5;

DxfDocument dxf = new DxfDocument();

// if you want to convert the vertexes of the polyline to WCS (World Coordinate System), you can
Vector3 v1OCS = new Vector3(v1.Location.X, v1.Location.Y, lwp.Elevation);
Vector3 v2OCS = new Vector3(v2.Location.X, v2.Location.Y, lwp.Elevation);
Vector3 v3OCS = new Vector3(v3.Location.X, v3.Location.Y, lwp.Elevation);
List<Vector3> vertexesWCS = MathHelper.Transform(new List<Vector3> { v1OCS, v2OCS, v3OCS }, lwp.Normal, MathHelper.CoordinateSystem.Object, MathHelper.CoordinateSystem.World);
Hope this helps,