if (ml.ContentType == ContentType.BlockContent)
{
DBObjectCollection dbOC
= new DBObjectCollection
(); ml.Explode(dbOC);
double existingBlockAngle = 0.0d;
foreach (DBObject dbo in dbOC)
{
if (dbo.GetRXClass().Name == "AcDbBlockReference")
{
BlockReference br = (BlockReference)dbo;
existingBlockAngle = br.Rotation;
break;
}
}
Matrix3d fixedRotation = Matrix3d.Rotation( -1.0d * existingBlockAngle, Vector3d.ZAxis, ml.GetFirstVertex(0));
ml.TransformBy(fixedRotation);
}