Hi Felix !, Try this code, I hope you can be useful! I found the access in the API. Best regards!
' a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
MessageBox.Show("File is not a sheet metal part.", "iLogic")
Exit Sub
End If
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition
' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
Try
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
'Else
'oCompDef.FlatPattern.Edit
End If
Catch
MessageBox.Show("Error editting the flat pattern.", "iLogic")
End Try
End If
' a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern = oCompDef.FlatPattern' ThisApplication.ActiveEditObject
Dim oFace As Face = oFlatPattern.TopFace ' = oFlatPattern.BottomFace
Dim oSketch As PlanarSketch
oSketch = oFlatPattern.Sketches.Add(oFace)', False)
oSketch.Name = "My_Sketch"
'--------------------------------------------------
Dim sText As String = "Here is the last and final line of text."
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
oTextBox = oSketch.TextBoxes.AddByRectangle(oTG.CreatePoint2d(oSketch.OriginPointGeometry.X, _
oSketch.OriginPointGeometry.Y), oTG.CreatePoint2d(0,2), sText)
' supports only 0, pi/2, pi, 1.5pi
oTextBox.Rotation = PI/2 'Math.Atan(1) * 2
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn