Donnerstag, 11. März 2010

Coordinate System Riding In Autocad

In Autocad workspace every geometric point is defined in World Coordinate System (WCS), but sometimes it's usefull to work in a coordinate system relative to an object or block.

To translate the coordinates of a point (vector, matrix) we need to obtain the ECS property (a mere transformation matrix) to which the entity relates. Then it's:

BlockReference blkref = // set to a valid BlockReference
// Transform from WCS to OCS
Point3d OcsPosition =
blkRef.Position.TransformBy(blkref.Ecs.Inverse() );
// Transform from OCS to WCS:
Point3d WcsPosition = OcsPosition.TransformBy(blkref.Ecs);

Enjoy.