
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
A "noob" question im afriad regarding converting angles between co-ordinate systems in AutoCAD .NET. Im struggling to find much on the subject and would appriciate some help or a point in the right direction.
The Problem:
Im creating my first little utility to form selected block attibute references into a nice neat list. The current version takes a selection of blocks and a list insert location and then moves the attribute references to the location and rotates them to WCS angle of 0.
I now want to expand the program to make it a little more flexible and allow you to form the list parrallel to the currently selected UCS x axis (the i.e. and angle of 0 in relation to current ucs's).
I have managed bumble my way through and transform the attribute positions correctly to form a list relative to the current UCS but am strugling on how to work out in code what the equivlanent WCS angle value would be.
I have done some calcs using .net framework to calculate an angle between two vectors (see code extract below). But this introduces a small error into the angles (i.e. if my ucs is set rotated 45 degrees around the zed and i use the below maths, the resulatant angle is 45.0000002 when read in acad afterwards).
Matrix3d ucsCur = ed.CurrentUserCoordinateSystem;
CoordinateSystem3d cs = ucsCur.CoordinateSystem3d;
// the below seems to work by calugulating the angle between two vetrex using .net maths class but this introduce a small accuracy error. Is there a better way?
Double rotAngle = Math.Acos((1 * cs.Xaxis.X) + (0 * cs.Xaxis.Y) + (0 * cs.Xaxis.Z));
//set the attribute reference rotation to the calculated WCS radian rotation value "rotAngle"
attRef.Rotation = rotAngle;
Im sure there is a better way built into the managed autocad wrapper using a tranform matix and the ucs vertex information but dont really know how to go about it. Any ideas? Also, if anyone know of any links explaining how to work with the UCS in .net they would be appriciated.
Regards,
Richard.
Solved! Go to Solution.