Hello together,
I try to automatically place and emboss text. How could I calculate the embossed text lengt and the angle?
Thank you very much
Georg
I think it depends, the Face the text wrap to and the text orientation both should be considered for calculate the length and angle. For the sample in your picture, the emboss is on a cylinder face, and the text is a normal text(not the geometry text) I think you can just create a sketch on the end face of the cylinder, and project the emboss edges onto the sketch, and then you can easily create a circular arc which use the center of the cylinder end face and the projected farmost points and then create a arc length dimension, like below picture shows:
But for other situation I think you need to calculate it case by case. Hope this helps.
Not easy I think, multiple cases should be considered, like the Face type(planar, cylindrical, conical), and also the text orientation all should be considered, also I think you should just consider the general Text but not the Geometry Text.
@YuhanZhang Is there a possibility to calculate only the text length?
This does not work:
Dim text1 As String = "Measure this text" Dim arialBold As New Font("Arial", 12.0F) Dim s As Size = TextRenderer.MeasureText(text1, arialBold) Dim bmp As New Bitmap(s.Width, s.Height) Dim WidthMM As Decimal = ((s.Width * 25.4) / bmp.HorizontalResolution) Dim WidthCM As Decimal = WidthMM / 10 Dim WidthInch As Decimal = WidthMM / 25.4 MsgBox("Text Width: " & s.Width & " Pixels" & vbCrLf & "Text Width: " & WidthMM & " mm" & vbCrLf & "Text Width: " & WidthCM & " cm" & vbCrLf & "Text Width: " & WidthInch & " Inches")
The TextBox itself has the properties(Height/Width and RangeBox) to return the size of the text, but this only works when the TextBox.Fitted returns True. I have not investigated TextRenderer, but if you currently can make the TextBox as fitted I think you can get its size as expected, otherwise you can log to IdeaStation about to expose new API to make a TextBox fitted.
Just recalled that we already have the TextBox.FittedTextHeight and FittedTextWidth exposed, so you can get the text size using these two properties. Hope this helps.
Can't find what you're looking for? Ask the community or share your knowledge.