Can be runned e.g. with AfterSave Event Trigger (I'm runnig it via addin independently on part):
Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Try
Dim oSMCD As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If oSMCD.HasFlatPattern Then
oSMCD.FlatPattern.Edit
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2000" _
+ "&OuterProfileLayer=IV_INTERIOR_PROFILES" _
+ "&InvisibleLayers=IV_TANGENT" _
+ "&SimplifySplines=True" _
+ "&BendLayerLineType=37634" _
+ "&BendLayerColor=255;255;0" _
+ "&BendUpLayerLineType=37634" _
+ "&BendUpLayerColor=255;255;0" _
+ "&BendDownLayerLineType=37634" _
+ "&BendDownLayerColor=255;255;0" _
+ "&FeatureProfilesLayerLineType=37634" _
+ "&FeatureProfilesLayerColor=255;255;0" _
+ "&FeatureProfilesUpLayerLineType=37634" _
+ "&FeatureProfilesUpLayerColor=255;255;0" _
+ "&FeatureProfilesDownLayerLineType=37634" _
+ "&FeatureProfilesDownLayerColor=255;255;0"
Dim sFN As String = ThisDoc.FileName(False)
Dim sPath As String = ThisDoc.Path
sFN = sPath & "\" & sFN & ".dxf"
oSMCD.DataIO.WriteDataToFile( sOut, sFN)
End If
Catch
MsgBox ("Couldn't save the DXF file.")
End Try
oSMCD.FlatPattern.ExitEdit()
End If
Checks if the part is Sheet Metal Part, then if there is the flat pattern it will export it to DXF.
Some lines (e.g. Bend Lines) are set to discontinuous (37634) and it's color to yellow (255;255;0). Tangent Lines are hidden (InvisibleLayers=IV_TANGENT)
This is the base code. I have some more added to it so then it does:
-Creates the flat pattern if it doesn't exist.
-Adds "Part Number" on the flat pattern (will be exported as yellow).
-Asks the designer if the position of the "Part number" is correct, if not than it lets him change it by form (he can rotate or change the text size in the form or just drag it to the correct position).
-Exports the whole thing to DXF with name defined by rule to folder defined by rule.
-Connects the DXF to the part file (via custom Parameters).
And some other things...
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods