Problems extrancting text

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
catalin
Posts: 1
Joined: 09 Oct 2007, 10:44

Problems extrancting text

Post by catalin » 09 Oct 2007, 11:00

Hello,

I have some problems extracting texts:
I used a modified version of the example from extended version of CAD Import .NET -> Import example to extract texts and attdefs in order to create text objects in an application we use and the problem is that this code does not extract the properties correctly for all types of text.
This code works for dxf files created with Corel but does not work with dxf files created by Autocad because in Autocad the height of the text is read much higher than it is in reality (although the position, the length and the angle seem ok).
Also the method we used to extract the font type only works for Corel files and doesn't work for Autocad files.

Code: Select all

			CADConst.DoScale2D(ref cadParams);
			DPoint dptStart = sender.StartPoint; //sender is CADText
			dptStart.Y += sender.Height * 1.3; //we don't know the meaning of this line - it was taken from your example
			PointF ptStart = TransformPoint(cadParams.matrix.PtXMat(dptStart)); //Right now TransformPoint is actually FCADImage.GetPoint()
			PointF ptUpLeft = TransformPoint(new DPoint(sender.Box.left, sender.Box.top, sender.Box.z1));
			PointF ptDownRight = TransformPoint(new DPoint(sender.Box.right, sender.Box.bottom, sender.Box.z2));
			float width = Math.Abs(ptDownRight.X - ptUpLeft.X);
			float height = Math.Abs(ptDownRight.Y - ptUpLeft.Y); //this is ok for Corel files but is always too big for Autocad files
			string txt = sender.Text;

			if (txt.Length > 0 && width > 0 && height > 0)
			{
				RectangleF rectBounds = new RectangleF((float)Math.Abs(ptStart.X), (float)Math.Abs(ptStart.Y), (float)Math.Abs(width), (float)Math.Abs(height));
				SDiagram.TextNode text = new Syncfusion.Windows.Forms.Diagram.TextNode(txt, rectBounds);
				text.PinPoint = ptStart;
				text.PinPointOffset = new SizeF(0,0);
				text.RotationAngle = -(sender.Rotation + cadParams.angle);
				text.FontStyle.Size = height;

				text.LineStyle.LineColor = Color.Transparent;
				text.NoClip = false;

				try
				{
					string fontName = cadParams.insert.EntName.Substring(3,cadParams.insert.EntName.IndexOf(";") - 3); //this method works only for Corel files
					text.FontStyle.Family = fontName;
				}
				catch 
				{
				}
			}

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 09 Oct 2007, 12:31

Dear Catalin,

Usually AutoCAD files use SHX fonts. Using of standard GDI+ means for drawing SHX texts will give wrong result in most cases. That is why CAD Import .NET contains own system for drawing texts.

To give an accurate answer how your application has to be modified, we need the whole ready to compile project with appropriate example files

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

Post Reply