Hello MateriaGris,
found out how to project the Flat pattern edges and bend lines and bring the sketch intend to the folded model.
Got some code of a similar topic from here:
https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/sketch-on-flat-pattern-issue/td-p/71...
Only the orientation and position of the sketch in the folded model is wrong:
I'm sure this task can be solved as well. Pleas feel free to further develop this code
Sub Main
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
' 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
oFlatPattern = ThisApplication.ActiveEditObject
Dim oFace As Face
oFace = oFlatPattern.TopFace
Dim oSketch As PlanarSketch
'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
If oSketch.Name = sSketchName Then
oSketch.Delete
End If
Next
' Create a new sketch.
' the Second argument specifies To include/Not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)
' Change the name.
oSketch.Name = sSketchName
Dim oEdges As Edges
UpEdges = oFlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True)
For Each Upedge In UpEdges
Dim line As SketchLine = oSketch.AddByProjectingEntity(Upedge)
Next
DownEdges = oFlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True)
For Each DownEdge In DownEdges
Dim line As SketchLine = oSketch.AddByProjectingEntity(DownEdges)
Next
For Each oEdge In oFlatPattern.TopFace.Edges
Call oSketch.AddByProjectingEntity(oEdge)
Next
oCompDef.FlatPattern.ExitEdit
Dim oFace2 As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to add flat sketch")
Dim oSketch2 As PlanarSketch
oSketch2 = oCompDef.Sketches.Add(oFace2,True)
oSketch.CopyContentsTo(oSketch2)
oPartDoc.Save
End Sub