protected override void CalculteReferencePoints() { defPoint = center; if (TextPositionManuallySet) { SetDimensionLinePosition(textRefPoint); } else { DimensionStyleOverride styleOverride; double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double arrowSize = Style.ArrowSize; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.ArrowSize, out styleOverride)) { arrowSize = (double)styleOverride.Value; } Vector2 vec = Vector2.Normalize(refPoint - center); double minOffset = (2 * arrowSize + textGap) * scale; textRefPoint = refPoint + minOffset * vec; } }
/// <summary> /// Calculates the reference point and dimension offset from a point along the dimension line. /// </summary> /// <param name="point">Point along the dimension line.</param> public void SetDimensionLinePosition(Vector2 point) { double radius = Vector2.Distance(center, refPoint); double rotation = Vector2.Angle(center, point); defPoint = center; refPoint = Vector2.Polar(center, radius, rotation); if (!TextPositionManuallySet) { DimensionStyleOverride styleOverride; double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double arrowSize = Style.ArrowSize; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.ArrowSize, out styleOverride)) { arrowSize = (double)styleOverride.Value; } Vector2 vec = Vector2.Normalize(refPoint - center); double minOffset = (2 * arrowSize + textGap) * scale; textRefPoint = refPoint + minOffset * vec; } }
/// <summary> /// Calculate the dimension reference points. /// </summary> protected override void CalculteReferencePoints() { DimensionStyleOverride styleOverride; double measure = Measurement; Vector2 ref1 = firstRefPoint; Vector2 ref2 = secondRefPoint; Vector2 midRef = Vector2.MidPoint(ref1, ref2); double dimRotation = Rotation * MathHelper.DegToRad; Vector2 vec = Vector2.Normalize(Vector2.Rotate(Vector2.UnitY, dimRotation)); Vector2 midDimLine = midRef + offset * vec; double cross = Vector2.CrossProduct(ref2 - ref1, vec); if (cross < 0) { firstRefPoint = ref2; secondRefPoint = ref1; } defPoint = midDimLine - measure * 0.5 * Vector2.Perpendicular(vec); if (TextPositionManuallySet) { DimensionStyleFitTextMove moveText = Style.FitTextMove; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride)) { moveText = (DimensionStyleFitTextMove)styleOverride.Value; } if (moveText == DimensionStyleFitTextMove.BesideDimLine) { SetDimensionLinePosition(textRefPoint); } } else { double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; if (dimRotation > MathHelper.HalfPI && dimRotation <= MathHelper.ThreeHalfPI) { gap = -gap; } textRefPoint = midDimLine + gap * vec; } }
public void SetDimensionLinePosition(Vector2 point, bool updateRefs) { if (updateRefs) { Vector2 refStart = start; Vector2 refEnd = end; Vector2 dirStart = refStart - center; Vector2 dirEnd = refEnd - center; Vector2 dirPoint = point - center; double cross = Vector2.CrossProduct(dirStart, dirEnd); double cross1 = Vector2.CrossProduct(dirStart, dirPoint); double cross2 = Vector2.CrossProduct(dirEnd, dirPoint); if (cross >= 0) { if (!(cross1 >= 0 && cross2 < 0)) { start = refEnd; end = refStart; } } else if (cross1 < 0 && cross2 >= 0) { start = refEnd; end = refStart; } } offset = Vector2.Distance(center, point); double startAngle = Vector2.Angle(center, start); double midRot = startAngle + Measurement * MathHelper.DegToRad * 0.5; Vector2 midDim = Vector2.Polar(center, offset, midRot); defPoint = midDim; if (!TextPositionManuallySet) { DimensionStyleOverride styleOverride; double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; textRefPoint = midDim + gap * Vector2.Normalize(midDim - center); } }
/// <summary> /// Calculates the dimension offset from a point along the dimension line. /// </summary> /// <param name="point">Point along the dimension line.</param> public void SetDimensionLinePosition(Vector2 point) { Vector2 ref1 = firstRefPoint; Vector2 ref2 = secondRefPoint; Vector2 midRef = Vector2.MidPoint(ref1, ref2); //Vector2 dimRef = this.DefinitionPoint; Vector2 refDir = Vector2.Normalize(secondRefPoint - firstRefPoint); double dimRotation = rotation * MathHelper.DegToRad; Vector2 dimDir = new Vector2(Math.Cos(dimRotation), Math.Sin(dimRotation)); double cross = Vector2.CrossProduct(refDir, point - firstRefPoint); if (cross < 0) { Vector2 tmp = firstRefPoint; firstRefPoint = secondRefPoint; secondRefPoint = tmp; Rotation += 180; dimRotation = rotation * MathHelper.DegToRad; } offset = MathHelper.PointLineDistance(midRef, point, dimDir); Vector2 offsetDir = Vector2.Rotate(Vector2.UnitY, dimRotation); Vector2 midDimLine = midRef + offset * offsetDir; defPoint = midDimLine - Measurement * 0.5 * Vector2.Perpendicular(Vector2.Normalize(offsetDir)); if (!TextPositionManuallySet) { DimensionStyleOverride styleOverride; double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; if (dimRotation > MathHelper.HalfPI && dimRotation <= MathHelper.ThreeHalfPI) { gap = -gap; } textRefPoint = midDimLine + gap * offsetDir; } }
private Vector2 CalculateHookLine() { if (vertexes.Count < 2) { throw new Exception("The leader vertexes list requires at least two points."); } DimensionStyleOverride styleOverride; double dimScale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { dimScale = (double)styleOverride.Value; } double arrowSize = Style.ArrowSize; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.ArrowSize, out styleOverride)) { arrowSize = (double)styleOverride.Value; } Vector2 v = Vertexes[Vertexes.Count - 1] - Vertexes[Vertexes.Count - 2]; Vector2 dir = v.X >= 0 ? Vector2.UnitX : -Vector2.UnitX; if (annotation != null) { switch (annotation.Type) { case EntityType.MText: dir = Vector2.Rotate(dir, ((MText)annotation).Rotation * MathHelper.DegToRad); break; case EntityType.Text: dir = Vector2.Rotate(dir, ((Text)annotation).Rotation * MathHelper.DegToRad); break; case EntityType.Insert: dir = Vector2.Rotate(dir, ((Insert)annotation).Rotation * MathHelper.DegToRad); break; case EntityType.Tolerance: dir = Vector2.Rotate(dir, ((Tolerance)annotation).Rotation * MathHelper.DegToRad); break; default: throw new ArgumentException("Only MText, Text, Insert, and Tolerance entities are supported as a leader annotation.", nameof(annotation)); } } return(Hook - dir * arrowSize * dimScale); }
/// <summary> /// Calculate the dimension reference points. /// </summary> protected override void CalculteReferencePoints() { DimensionStyleOverride styleOverride; double measure = Measurement * MathHelper.DegToRad; Vector2 center = CenterPoint; if (Vector2.IsNaN(center)) { throw new ArgumentException("The two lines that define the dimension are parallel."); } double startAngle = Vector2.Angle(center, endFirstLine); double midRot = startAngle + measure * 0.5; Vector2 midDim = Vector2.Polar(center, offset, midRot); defPoint = endSecondLine; arcDefinitionPoint = midDim; if (TextPositionManuallySet) { DimensionStyleFitTextMove moveText = Style.FitTextMove; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride)) { moveText = (DimensionStyleFitTextMove)styleOverride.Value; } if (moveText == DimensionStyleFitTextMove.BesideDimLine) { SetDimensionLinePosition(textRefPoint, false); } } else { double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; textRefPoint = midDim + gap * Vector2.Normalize(midDim - center); } }
/// <summary> /// Calculate the dimension reference points. /// </summary> protected override void CalculteReferencePoints() { DimensionStyleOverride styleOverride; Vector2 ref1 = FirstReferencePoint; Vector2 ref2 = SecondReferencePoint; Vector2 dirRef = ref2 - ref1; Vector2 dirDesp = Vector2.Normalize(Vector2.Perpendicular(dirRef)); Vector2 vec = offset * dirDesp; Vector2 dimRef1 = ref1 + vec; Vector2 dimRef2 = ref2 + vec; defPoint = dimRef2; if (TextPositionManuallySet) { DimensionStyleFitTextMove moveText = Style.FitTextMove; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride)) { moveText = (DimensionStyleFitTextMove)styleOverride.Value; } if (moveText == DimensionStyleFitTextMove.BesideDimLine) { SetDimensionLinePosition(textRefPoint); } } else { double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; textRefPoint = Vector2.MidPoint(dimRef1, dimRef2) + gap * dirDesp; } }
/// <summary> /// Calculate the dimension reference points. /// </summary> protected override void CalculteReferencePoints() { DimensionStyleOverride styleOverride; double measure = Measurement; double startAngle = Vector2.Angle(center, start); double midRot = startAngle + measure * MathHelper.DegToRad * 0.5; Vector2 midDim = Vector2.Polar(center, offset, midRot); defPoint = midDim; if (TextPositionManuallySet) { DimensionStyleFitTextMove moveText = Style.FitTextMove; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride)) { moveText = (DimensionStyleFitTextMove)styleOverride.Value; } if (moveText == DimensionStyleFitTextMove.BesideDimLine) { SetDimensionLinePosition(textRefPoint, false); } } else { double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; textRefPoint = midDim + gap * Vector2.Normalize(midDim - center); } }
/// <summary> /// Calculate the dimension reference points. /// </summary> protected override void CalculteReferencePoints() { if (TextPositionManuallySet) { DimensionStyleFitTextMove moveText = Style.FitTextMove; DimensionStyleOverride styleOverride; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride)) { moveText = (DimensionStyleFitTextMove)styleOverride.Value; } if (moveText != DimensionStyleFitTextMove.OverDimLineWithoutLeader) { secondPoint = textRefPoint; } } else { textRefPoint = secondPoint; } }
/// <summary> /// Calculates the dimension offset from a point along the dimension line. /// </summary> /// <param name="point">Point along the dimension line.</param> public void SetDimensionLinePosition(Vector2 point) { Vector2 refDir = Vector2.Normalize(secondRefPoint - firstRefPoint); Vector2 offsetDir = point - firstRefPoint; double cross = Vector2.CrossProduct(refDir, offsetDir); if (cross < 0) { Vector2 tmp = firstRefPoint; firstRefPoint = secondRefPoint; secondRefPoint = tmp; refDir *= -1; } Vector2 vec = Vector2.Perpendicular(refDir); offset = MathHelper.PointLineDistance(point, firstRefPoint, refDir); defPoint = secondRefPoint + offset * vec; if (!TextPositionManuallySet) { DimensionStyleOverride styleOverride; double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = offset + textGap * scale; textRefPoint = Vector2.MidPoint(firstRefPoint, secondRefPoint) + gap * vec; } }
private void SetDimensionLinePosition(Vector2 point, bool updateRefs) { Vector2 center = CenterPoint; if (Vector2.IsNaN(center)) { throw new ArgumentException("The two lines that define the dimension are parallel."); } if (updateRefs) { double cross = Vector2.CrossProduct(EndFirstLine - StartFirstLine, EndSecondLine - StartSecondLine); if (cross < 0) { Vector2 temp1 = startFirstLine; Vector2 temp2 = endFirstLine; startFirstLine = startSecondLine; endFirstLine = endSecondLine; startSecondLine = temp1; endSecondLine = temp2; } Vector2 ref1Start = StartFirstLine; Vector2 ref1End = EndFirstLine; Vector2 ref2Start = StartSecondLine; Vector2 ref2End = EndSecondLine; Vector2 dirRef1 = ref1End - ref1Start; Vector2 dirRef2 = ref2End - ref2Start; Vector2 dirOffset = point - center; double crossStart = Vector2.CrossProduct(dirRef1, dirOffset); double crossEnd = Vector2.CrossProduct(dirRef2, dirOffset); if (crossStart >= 0 && crossEnd >= 0) { StartFirstLine = ref2Start; EndFirstLine = ref2End; StartSecondLine = ref1End; EndSecondLine = ref1Start; } else if (crossStart < 0 && crossEnd >= 0) { StartFirstLine = ref1End; EndFirstLine = ref1Start; StartSecondLine = ref2End; EndSecondLine = ref2Start; } else if (crossStart < 0 && crossEnd < 0) { StartFirstLine = ref2End; EndFirstLine = ref2Start; StartSecondLine = ref1Start; EndSecondLine = ref1End; } } offset = Vector2.Distance(center, point); defPoint = endSecondLine; double measure = Measurement * MathHelper.DegToRad; double startAngle = Vector2.Angle(center, endFirstLine); double midRot = startAngle + measure * 0.5; Vector2 midDim = Vector2.Polar(center, offset, midRot); arcDefinitionPoint = midDim; if (!TextPositionManuallySet) { DimensionStyleOverride styleOverride; double textGap = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textGap = (double)styleOverride.Value; } double scale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { scale = (double)styleOverride.Value; } double gap = textGap * scale; textRefPoint = midDim + gap * Vector2.Normalize(midDim - center); } }
/// <summary> /// Resets the annotation position according to the leader hook. /// </summary> private void ResetAnnotationPosition() { if (vertexes.Count < 2) { throw new Exception("The leader vertexes list requires at least two points."); } if (annotation == null) { return; } DimensionStyleOverride styleOverride; DimensionStyleTextVerticalPlacement textVerticalPlacement = Style.TextVerticalPlacement; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextVerticalPlacement, out styleOverride)) { textVerticalPlacement = (DimensionStyleTextVerticalPlacement)styleOverride.Value; } double textOffset = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textOffset = (double)styleOverride.Value; } double dimScale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { dimScale = (double)styleOverride.Value; } double textHeight = Style.TextHeight; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextHeight, out styleOverride)) { textHeight = (double)styleOverride.Value; } AciColor textColor = Style.TextColor; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextColor, out styleOverride)) { textColor = (AciColor)styleOverride.Value; } Vector2 hook = vertexes[vertexes.Count - 1]; Vector2 position; switch (annotation.Type) { case EntityType.MText: MText mText = (MText)annotation; Vector2 dir = vertexes[vertexes.Count - 1] - vertexes[vertexes.Count - 2]; double mTextXoffset = 0.0; int mTextSide = Math.Sign(dir.X); if (textVerticalPlacement == DimensionStyleTextVerticalPlacement.Centered) { if (mTextSide >= 0) { mText.AttachmentPoint = MTextAttachmentPoint.MiddleLeft; mTextXoffset = -textOffset * dimScale; } else { mText.AttachmentPoint = MTextAttachmentPoint.MiddleRight; mTextXoffset = textOffset * dimScale; } position = hook; } else { position = hook + new Vector2(mTextSide * textOffset * dimScale, textOffset * dimScale); mText.AttachmentPoint = mTextSide >= 0 ? MTextAttachmentPoint.BottomLeft : MTextAttachmentPoint.BottomRight; } position = position + offset; mText.Position = MathHelper.Transform(new Vector3(position.X - mTextXoffset, position.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World); mText.Height = textHeight * dimScale; mText.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; case EntityType.Insert: Insert ins = (Insert)annotation; position = hook + offset; ins.Position = MathHelper.Transform(new Vector3(position.X, position.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World); ins.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; case EntityType.Tolerance: Tolerance tol = (Tolerance)annotation; position = hook + offset; tol.Position = MathHelper.Transform(new Vector3(position.X, position.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World); tol.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; case EntityType.Text: Text text = (Text)annotation; double textXoffset = 0.0; Vector2 textDir = vertexes[vertexes.Count - 1] - vertexes[vertexes.Count - 2]; int textSide = Math.Sign(textDir.X); if (textVerticalPlacement == DimensionStyleTextVerticalPlacement.Centered) { if (textSide >= 0) { text.Alignment = TextAlignment.MiddleLeft; textXoffset = -textOffset * dimScale; } else { text.Alignment = TextAlignment.MiddleRight; textXoffset = textOffset * dimScale; } position = hook; } else { position = hook + new Vector2(textSide * textOffset * dimScale, textOffset * dimScale); text.Alignment = textSide >= 0 ? TextAlignment.BottomLeft : TextAlignment.BottomRight; } position = position + offset; text.Position = MathHelper.Transform(new Vector3(position.X - textXoffset, position.Y, elevation), Normal, CoordinateSystem.Object, CoordinateSystem.World); text.Height = textHeight * dimScale; text.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; default: throw new Exception(string.Format("The entity type: {0} not supported as a leader annotation.", annotation.Type)); } }
/// <summary> /// Resets the leader hook position according to the annotation position. /// </summary> private void ResetHookPosition() { if (vertexes.Count < 2) { throw new Exception("The leader vertexes list requires at least two points."); } if (annotation == null) { return; } DimensionStyleOverride styleOverride; DimensionStyleTextVerticalPlacement textVerticalPlacement = Style.TextVerticalPlacement; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextVerticalPlacement, out styleOverride)) { textVerticalPlacement = (DimensionStyleTextVerticalPlacement)styleOverride.Value; } double textOffset = Style.TextOffset; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride)) { textOffset = (double)styleOverride.Value; } double dimScale = Style.DimScaleOverall; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride)) { dimScale = (double)styleOverride.Value; } double textHeight = Style.TextHeight; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextHeight, out styleOverride)) { textHeight = (double)styleOverride.Value; } AciColor textColor = Style.TextColor; if (StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextColor, out styleOverride)) { textColor = (AciColor)styleOverride.Value; } Vector3 ocsHook; switch (annotation.Type) { case EntityType.MText: MText mText = (MText)annotation; ocsHook = MathHelper.Transform(mText.Position, Normal, CoordinateSystem.World, CoordinateSystem.Object); int mTextSide = Math.Sign(ocsHook.X - vertexes[vertexes.Count - 2].X); if (textVerticalPlacement == DimensionStyleTextVerticalPlacement.Centered) { double xOffset; if (mTextSide >= 0) { mText.AttachmentPoint = MTextAttachmentPoint.MiddleLeft; xOffset = -textOffset * dimScale; } else { mText.AttachmentPoint = MTextAttachmentPoint.MiddleRight; xOffset = textOffset * dimScale; } vertexes[vertexes.Count - 1] = new Vector2(ocsHook.X + xOffset, ocsHook.Y) - offset; } else { ocsHook -= new Vector3(mTextSide * textOffset * dimScale, textOffset * dimScale, 0.0); mText.AttachmentPoint = mTextSide >= 0 ? MTextAttachmentPoint.BottomLeft : MTextAttachmentPoint.BottomRight; vertexes[vertexes.Count - 1] = new Vector2(ocsHook.X, ocsHook.Y) - offset; } mText.Height = textHeight * dimScale; mText.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; case EntityType.Insert: Insert ins = (Insert)annotation; ocsHook = MathHelper.Transform(ins.Position, Normal, CoordinateSystem.World, CoordinateSystem.Object); vertexes[vertexes.Count - 1] = new Vector2(ocsHook.X, ocsHook.Y) - offset; ins.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; case EntityType.Tolerance: Tolerance tol = (Tolerance)annotation; ocsHook = MathHelper.Transform(tol.Position, Normal, CoordinateSystem.World, CoordinateSystem.Object); vertexes[vertexes.Count - 1] = new Vector2(ocsHook.X, ocsHook.Y) - offset; tol.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; case EntityType.Text: Text text = (Text)annotation; ocsHook = MathHelper.Transform(text.Position, Normal, CoordinateSystem.World, CoordinateSystem.Object); int textSide = Math.Sign(ocsHook.X - vertexes[vertexes.Count - 2].X); if (textVerticalPlacement == DimensionStyleTextVerticalPlacement.Centered) { double xOffset; if (textSide >= 0) { text.Alignment = TextAlignment.MiddleLeft; xOffset = -textOffset * dimScale; } else { text.Alignment = TextAlignment.MiddleRight; xOffset = textOffset * dimScale; } vertexes[vertexes.Count - 1] = new Vector2(ocsHook.X + xOffset, ocsHook.Y) - offset; } else { ocsHook -= new Vector3(textSide * textOffset * dimScale, textOffset * dimScale, 0.0); text.Alignment = textSide >= 0 ? TextAlignment.BottomLeft : TextAlignment.BottomRight; vertexes[vertexes.Count - 1] = new Vector2(ocsHook.X, ocsHook.Y) - offset; } text.Height = textHeight * dimScale; text.Color = textColor.IsByBlock ? AciColor.ByLayer : textColor; break; default: throw new Exception(string.Format("The entity type: {0} not supported as a leader annotation.", annotation.Type)); } }