Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JelteDeJong
in reply to: JelteDeJong

After reading this post i realised there is a better way to do this.

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
If (def.HasFlatPattern) Then
	def.FlatPattern.Edit()
Else
	def.Unfold()
End If

Dim flat As FlatPattern = def.FlatPattern
Dim edgeloops As EdgeLoops = flat.TopFace.EdgeLoops

Dim oMeasure As MeasureTools = ThisApplication.MeasureTools
Dim outerPerimeter As Double = 0
Dim breakthroughsPerimeter As Double = 0
For Each edgeLoop As EdgeLoop In edgeloops
	' length is multiplied by 10 to convert cm to mm
	Dim edgeLength = oMeasure.GetLoopLength(EdgeLoop) * 10

	If (EdgeLoop.IsOuterEdgeLoop) Then
		outerPerimeter = outerPerimeter + edgeLength
	Else
		breakthroughsPerimeter = breakthroughsPerimeter + edgeLength
	End If
Next
flat.ExitEdit()
MsgBox("Number of bends: " & def.Bends.Count & System.Environment.NewLine &
		"Number of edge loops (that includes outerprofile): " & edgeloops.Count & System.Environment.NewLine &
		"Number of breakthroughs: " & (edgeloops.Count - 1) & System.Environment.NewLine &
		"Total outer perimeter: " & Math.Round(outerPerimeter, 1) & System.Environment.NewLine &
		"Total breakthroughs perimeter: " & Math.Round(breakthroughsPerimeter, 2))

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com