
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a drawing with a group of items as a List<Entity>. One of those items is a reference line and I need to rotate all of these entities so that the reference line is aligned with the Y axis.
I'm trying to do something like this:
Vector3d rotationVector = referenceLine.StartPoint.GetVectorTo(referenceLine.EndPoint);
double rotationAngle = rotationVector.GetAngleTo(Vector3d.YAxis);
foreach (Entity ent in entities)
{
ent.TransformBy(Matrix3d.Rotation(rotationAngle, Vector3d.ZAxis, centerPoint));
}
But obviously this isn't working. Can someone please help point me in the right direction? I've tried several variations on this basic idea and I can get it working half the time, depending on the starting angle of the reference line, but it's never working for all angles. Not sure what I'm doing wrong here and sometimes AutoCAD is giving me fatal errors that can't be caught in a try/catch block. Thank you.
Solved! Go to Solution.