CadText inside CadHatch
Moderators: SDS, support, admin
-
- Posts: 2
- Joined: 12 Apr 2012, 17:35
CadText inside CadHatch
Greetings from Italy,
I have to insert programmatically a CadText in the same coordinates of a selected hatch.
I read this topic
http://www.cadsofttools.com/forum/viewt ... tity#p9888
and i tried to adapt the solution but i can't do it...
may someone help me?
VB or c# no problem...
If cadImage.SelectedEntities(0).EntType = EntityType.Hatch Then
...
end if
Many thanks
I have to insert programmatically a CadText in the same coordinates of a selected hatch.
I read this topic
http://www.cadsofttools.com/forum/viewt ... tity#p9888
and i tried to adapt the solution but i can't do it...
may someone help me?
VB or c# no problem...
If cadImage.SelectedEntities(0).EntType = EntityType.Hatch Then
...
end if
Many thanks
-
- Posts: 2
- Joined: 12 Apr 2012, 17:35
Re: CadText inside CadHatch
I found this solution...
Code: Select all
If cadImageFld.SelectedEntities(0).EntType = EntityType.CurvePolygon Then
Return CreateTextOnHatch(cadImageFld.SelectedEntities(0), "TEST", Color.Red)
End If
Code: Select all
Public Function CreateTextOnHatch(ByVal xEnt As CADImport.CADCurvePolygon, ByVal sText As String, ByVal xColor As System.Drawing.Color) As Boolean
Try
Dim dP As DPoint = xEnt.Box.TopLeft
CreateText(sText, 3, xColor, dP.X + 5, dP.Y - 5, dP.Z)
Return True
Catch ex As Exception
_strError = ex.Message
Return False
End Try
End Function
Code: Select all
Public Function CreateText(ByVal sText As String, ByVal TextHeight As Integer, ByVal xColor As System.Drawing.Color, ByVal x As Double, ByVal y As Double, ByVal z As Double) As Boolean
Try
Dim cText as New CADText
cText.Color = xColor
Try
cText.Point = New DPoint(x, y, z)
cText.Height = TextHeight
cText.Rotation = 0
cText.Text = sText
cadImageFld.Converter.GetSection(ConvSection.Entities).AddEntity(cText)
cadImageFld.Converter.OnCreate(cText)
cadImageFld.Converter.Loads(cText)
Catch exception As FormatException
_strError = exception.message
Return False
End Try
Catch ex As Exception
_strError = ex.message
Return False
End Try
End Function
Last edited by sevanrulez on 13 Apr 2012, 10:55, edited 1 time in total.
Re: CadText inside CadHatch
Hello.
Generally we recommend add a new entity to the current layout. CADStyle object can be used to specify text's font. Also please note, CADHatch entity represents hatched area in CAD Import .NET. Solid area represented by CADCurvePolygon.
Generally we recommend add a new entity to the current layout. CADStyle object can be used to specify text's font. Also please note, CADHatch entity represents hatched area in CAD Import .NET. Solid area represented by CADCurvePolygon.
Code: Select all
if (cadImage.SelectedEntities[0].EntType == EntityType.Hatch)
{
CADText entText = new CADText();
CADStyle txtStyle = new CADStyle();
txtStyle.Name = "Gothice";
txtStyle.PrimaryFont = "Gothice";
cadImage.Converter.Styles.Add(txtStyle);
entText.Style = (CADStyle)cadImage.Converter.Styles[cadImage.Converter.Styles.Count - 1];
entText.Color = Color.Red;
entText.Point = new DPoint(0, 0, 0); //specify coordinates here
entText.Height = 10;
entText.Rotation = 0;
entText.Text = "Hello World!!!";
entText.LineWeight = 0.1;
entText.Loaded(cadImage.Converter);
cadImage.Converter.Loads(entText);
cadImage.Converter.OnCreate(entText);
cadImage.CurrentLayout.AddEntity(entText);
cadImage.GetExtents();
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support