Calculates the position and angle of the Mtext object
zenggl
5/26/2022 9:35 AM
|
---|
If there is a rotate value in the Mtext object (as shown in the figure), how to calculate the drawing position and angle in Mtext
With the following code, the drawn text angle is inconsistent, and the original rotate value cannot be read out at the same time.
DxfMText MText = (DxfMText)item;
float x= (float)(MText.InsertionPoint.X);
float y = (float)(MText.InsertionPoint.Y);
float yAngle = -(float)(MText.XAxis.Y / Math.PI * 180);
StringFormat StringFormat = new StringFormat();
StringFormat.Alignment = StringAlignment.Near;
PointF cPoint = new PointF(x, y);
using (Matrix m = new Matrix())
{
m.RotateAt(yAngle, cPoint);
g.Transform = m;
g.DrawString(MText.SimplifiedText, new Font("宋体", (float)MText.Height), myPan, cPoint, textFormat);
g.ResetTransform();
}
|
Wout
5/26/2022 9:53 AM
|
---|
Hi,
Your yAngle calculation does not make sense at all. Also you're not taking into account the z-axis.
I suggest you just use DxfMText.Transform and create your Transform from that (you'll have to discard the 3rd row and column from the 4D matrix), which takes into account everything.
At least this doesn't look like a CadLib bug. For further support on this you'll have to order a support ticket here.
- Wout
|