Message 1 of 6
Would anybody be able to help with my code breaking flat patterns please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, please would someone be able to explain why my below code would break a flat pattern? My code opens the sheet metal and creates a flat pattern, and measure the thickness to see if the flat pattern has unfolded correctly. However once executing the flat pattern breaks (flanges are folded in the flat pattern view etc.), and the only fix is to delete the flat pattern and make a new one, where the code would then break it if ran again.
Here is my code:
If TypeOf oCompDocDef Is SheetMetalComponentDefinition Then
Dim oSheetMetal As SheetMetalComponentDefinition = oCompDocDef
oCompDoc.Update
oSheetMetal.Unfold
oSheetMetal.FlatPattern.Edit
'Check flat pattern has unfolded correctly
Dim flatPatternThickness As Double = ((oCompDocDef.Parameters.ModelParameters.Item("Thickness").Value) * 10)
Dim rangeThickness As Double = (oSheetMetal.RangeBox.MaxPoint.Z - oSheetMetal.RangeBox.MinPoint.Z) * 10
If Round(flatPatternThickness) <> Round(rangeThickness) Then
' MessageBox.Show("Thickness parameter = " & flatPatternThickness & vbCrLf & "Thickness measured in model = " & rangeThickness)
errorMessage = oCompFileName & " - DXF not exported as the flat pattern did not unfold correctly"
oSheetMetal.FlatPattern.ExitEdit
oCompDoc.Close
GoTo dxfAbortion
End If
'Export DXF
Dim dxfFormat As String = "FLAT PATTERN DXF?AcadVersion=2000" & "&OuterProfileLayer=IV_OUTER_PROFILE&OuterProfileLayerLineType=37633&OuterProfileLayerLineWeight=0,0500&OuterProfileLayerColor=0;0;0" & "&InteriorProfilesLayer=IV_INTERIOR_PROFILES&InteriorProfilesLayerLineType=37633&InteriorProfilesLayerLineWeight=0,0500&InteriorProfilesLayerColor=0;0;0" & "&InvisibleLayers=IV_TANGENT;IV_BEND;IV_Bend_Down;IV_Bend_Up;IV_ARC_CENTERS"
exportFullPath = exportLocation & "\" & oCompFileNameWithoutExtension & " [" & oCompRevisionNumber.Value & "].dxf"
oSheetMetal.DataIO.WriteDataToFile(dxfFormat, exportFullPath)
oSheetMetal.FlatPattern.ExitEdit
GoTo dxfRepair
End If