Sketch - Project Flat Pattern using iLogic

Sketch - Project Flat Pattern using iLogic

MateriaGris
Contributor Contributor
693 Views
1 Reply
Message 1 of 2

Sketch - Project Flat Pattern using iLogic

MateriaGris
Contributor
Contributor

Hi everyone.
I need to use "Project Flat Pattern" on a sketch using ilogic.

MateriaGris_0-1651848605929.png

In this question from 2 years ago the topic is referred to, in my case I need to add points in the projection of the bending axes., but I can't find a way to do it automatically from within iLogic.

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/sketch-project-flat-pattern-api/td-p...

 

I am attaching an example file showing what I am interested in doing.


I really appreciate if you can help me.

 

 

0 Likes
694 Views
1 Reply
Reply (1)
Message 2 of 2

SevInventor
Advocate
Advocate

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

 

 

 

 

 

 

 

 

 

0 Likes