-
Hello, I am experiencing an issue with text alignment. When I generate a simple DXF and open it in DWG TrueView and SpinFire it looks how I anticipate with the text aligned // create a new document
DxfDocument doc = new DxfDocument();
doc.DrawingVariables.AcadVer = DxfVersion.AutoCad2018;
doc.DrawingVariables.InsUnits = DrawingUnits.Inches;
// position vector for text and circle
Vector3 pos = new Vector3(10, 3, 0);
// add text
Layer dataTextLayer = new Layer("textLayer");
dataTextLayer.Color.Index = 8;
TextStyle style = new TextStyle("Arial", FontStyle.Regular);
Text dataText = new Text("H", pos, 1.5)
{
Layer = dataTextLayer,
Rotation = 00.00,
Alignment = TextAlignment.MiddleCenter,
Style = style,
Color = AciColor.ByLayer,
Lineweight = Lineweight.W200,
WidthFactor = 1,
};
doc.AddEntity(dataText);
// add circle
Circle c = new Circle
{
Center = pos,
Radius = .2,
Layer = new Layer("circleLayer")
};
doc.AddEntity(c);
// add polyline border
double corrnerBuldge = -0.4;
double sideLengthX = 20;
double sideLengthY = 6.00;
double cornerRadius = 0.38;
List<LwPolylineVertex> vertexes = new List<LwPolylineVertex>()
{
// bottom left
new LwPolylineVertex(0 + cornerRadius, 0, corrnerBuldge),
new LwPolylineVertex(0, 0 + cornerRadius),
// top left
new LwPolylineVertex(0, sideLengthY - cornerRadius, corrnerBuldge),
new LwPolylineVertex(0 + cornerRadius, sideLengthY),
// top right
new LwPolylineVertex(sideLengthX - cornerRadius, sideLengthY, corrnerBuldge),
new LwPolylineVertex(sideLengthX, sideLengthY - cornerRadius),
// bottom right
new LwPolylineVertex(sideLengthX, 0 + cornerRadius, corrnerBuldge),
new LwPolylineVertex(sideLengthX - cornerRadius, 0),
};
LwPolyline poly = new LwPolyline(vertexes, true)
{
Layer = new Layer("polyline"),
};
doc.AddEntity(poly);
// save to file
doc.Save(path + ".dxf"); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The issue also appears in AutoCad. It looks like both AutoCad and eDrawings cannot find the specified |
Beta Was this translation helpful? Give feedback.
-
Not all programs have the same capabilities and may not read all the information stored in the DXF correctly. I do not see any problems loading your example with AutoCad, it shows the text in the correct place. If it works for DWG TrueView it should work for AutoCad and all its acolytes, an educated guess is that all of them share the same base code they are Autodesk products after all. My first suggestion is to use a MText entity instead of a Text. It is the default entity when writing texts in AutoCad, and I found that other programs behaves better with it. Just keep in mind that the equivalent to the Alignment property of the Text is called AttachmentPoint in the MText. The other solution is the hard one, leave the text alignment to the default and set the text position so that its center lies in the desired position. |
Beta Was this translation helpful? Give feedback.
Not all programs have the same capabilities and may not read all the information stored in the DXF correctly. I do not see any problems loading your example with AutoCad, it shows the text in the correct place. If it works for DWG TrueView it should work for AutoCad and all its acolytes, an educated guess is that all of them share the same base code they are Autodesk products after all.
My first suggestion is to use a MText entity instead of a Text. It is the default entity when writing texts in AutoCad, and I found that other programs behaves better with it. Just keep in mind that the equivalent to the Alignment property of the Text is called AttachmentPoint in the MText.
The other solut…