Given a sketch, I wish to get its profile paths (outer, plus inners), for each path, I wish to get their individual curves (line, arc, splines, any type). For lines, I need start and end points, for others, some sample points would do.
For "T" like thin profile shape, following code got me, 1 ProfilePath, which had 8 Lines (thus 8 points) and it worked fine.
For Each path As Inventor.ProfilePath In extFeature.Profile
If Not path Is Nothing And path.Count > 0 Then
For Each entity As Inventor.ProfileEntity In path
If entity.CurveType = Curve2dTypeEnum.kLineSegmentCurve2d Then
Dim oSkE As SketchEntity = entity.SketchEntity
Dim oLine As SketchLine = CType(oSkE, SketchLine)
Dim startpt As Inventor.Point2d = oLine.StartSketchPoint.Geometry
Dim endpt As Inventor.Point2d = oLine.EndSketchPoint.Geometry
But same logic does not work (crashes at Casting I guess) for "S" shape as below:
It gives path.Count == 0.
Any clues?
Could you please upload your test part file and code sub that produce Count = 0.
Thanks
Hi,
your code is not run-able. I used a simple code (just checking if the path exists) on a sketch which looks similar to "S". The code can return the path lines.
Could you provide your part file?
Hi Yogesh
it seems like you have a problem with uploading the files.
This site did not allow .sat file but I guess did the .ipt file.
Could you get the ipt? Its in my previous post. Attached here as well.
The code attached here has worked ok with the attached Part1.ipt but does not work with my part S.ipt. I had created this "S" profile by using the Text command in Sketching environment. You may want to try that as well.
Hi,
forget what I posted just now 🙂 I made a mistake. Actually, no any problem with the API. For TextBox path, it is correct that the PathProfile.Path is empty. To get the TextBox, access PathProfile.TextBox, next TextBox.BoundaryGeometry
Dim path As ProfilePath For Each path In extFeature.Profile If path.TextBoxPath Then Dim oTB As TextBox = path.TextBox Dim oOutlineColl As SketchEntitiesEnumerator = oTB.BoundaryGeometry Dim oEachEntity As SketchEntity For Each oEachEntity In oOutlineColl If TypeOf oEachEntity Is SketchLine Then Dim oSL As SketchLine = oEachEntity Dim oSTPt As SketchPoint = oSL.StartSketchPoint Dim oEndPt As SketchPoint = oSL.EndSketchPoint ElseIf TypeOf oEachEntity Is SketchSpline Then Else End If Next Else If path.Count > 0 Then For Each entity As Inventor.ProfileEntity In path If entity.CurveType = Curve2dTypeEnum.kLineSegmentCurve2d Then Dim oSkE As SketchEntity = entity.SketchEntity Dim oLine As SketchLine = CType(oSkE, SketchLine) Dim startpt As Inventor.Point2d = oLine.StartSketchPoint.Geometry Dim endpt As Inventor.Point2d = oLine.EndSketchPoint.Geometry End If Next End If End If Next
I debuged it further and found that in the 'TexBox' logic presented above, it does return 4 sketchentities but they are all lines, TextBox's bounding lines. I did not see the Splines of "S" coming there. Did I miss anything?
Hi,
you did not miss anything. I am wrong. We have a wish#1432685: retrieve geometry of text from sketch texboxes by API. I thought it has been implemented. When I saw "BoundaryGeometry", I was rushed to think it is that. However, it is actually the lines of the boundary of the TextBox. If you set TextBox.ShowBoundaries = true, you can see the 4 lines. Sorry for the misleading.
If you wanted to draw a client graphics from the strokes of the TextBox, you could consider to use GraphicsNode.AddTextGraphics. The TextBox.Style tells you the Font and Size of the TextBox, by which you could initialize TextGraphics.
If you must get the strokes, probably the Windows API FormattedText, PathGeometry may help a bit. I cannot guarantee, but this is what I can see by now.
Again, sorry for my misleading.