Determine if flat pattern has an error.

Determine if flat pattern has an error.

Anonymous
Not applicable
430 Views
3 Replies
Message 1 of 4

Determine if flat pattern has an error.

Anonymous
Not applicable

Hello,

I create custom sheetmetal styles from time to time via the API. It fails when the flat pattern has issues. Is there a way to determine if the flat pattern has errors/issues so I can delete it as required?

 

Eric

0 Likes
431 Views
3 Replies
Replies (3)
Message 2 of 4

jdkriek
Advisor
Advisor

I think something like this would cover the bases

 

Try
	Dim oPartDoc As PartDocument = ThisDoc.Document
	Dim oSMDef As SheetMetalComponentDefinition
	oSMDef = oPartDoc.ComponentDefinition
	' Detect if there is a flat pattern
	If oSMDef.FlatPattern Is Nothing Then 
		Throw New Exception("No Flat Pattern")
	Else
		MsgBox("Has Flat Pattern, but may have errors")
	End If
' Catch Any Errors
Catch ex As Exception
	MessageBox.Show(ex.ToString ,"Error")
	' Try to delete the pattern
	If ThisDoc.Document.ComponentDefinition.FlatPattern IsNot Nothing Then 
		ThisDoc.Document.ComponentDefinition.FlatPattern.Delete
	End If
End Try
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you for the reply, obtaining the flat pattern isn't a problem. I'm trying to determine if the flat pattern has errors or issues via the API. The following is the closest I can come up with. It is far from perfect as it doesn't tell me if the flat pattern itself has issues. Is this the closest I'm going to get?

Dim _shtMtlCompDef As SheetMetalComponentDefinition = _prtDoc.ComponentDefinition

                Dim _flatPatternFeatures As FlatPatternFeatures = _shtMtlCompDef.FlatPattern.Features
                For I As Integer = 0 To _flatPatternFeatures.Count
                    If _flatPatternFeatures(I).HealthStatus = HealthStatusEnum.kInErrorHealth Then
                        _shtMtlCompDef.FlatPattern.Delete()
                    End If
                Next I

 

0 Likes
Message 4 of 4

ekinsb
Alumni
Alumni

What kinds of issues do you typically see that you need to detect?


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes