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

Okay, then the issue was when the original code was pulling oDoc.FullFileName, it was pulling the full file path as well, and we didn't put that back and put the Part Number and file type behind that, the code didn't know where to save the file.  So we just need to add in a line of code to get the file path and add that to sFname:

 

SyntaxEditor Code Snippet

Dim oDoc As PartDocument
oDoc=ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef=oDoc.ComponentDefinition
Dim oDataIO As DataIO
oDataIO=oDoc.ComponentDefinition.DataIO
If oCompDef.HasFlatPattern=False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
Dim sOut As String
sOut="FLAT PATTERN DWG?AcadVersion=2000" _
+"&InvisibleLayers=IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _
+"&SimplifySplines=True" _
+"&LINEAR TOLERANCE=0.010" _
+"&MergeProfilesIntoPolyline=True" _
+"&RebaseGeometry=False" _
+"&TrimCenterlines=True"
Dim invPropSets As PropertySets 
invPropSets=oDoc.PropertySets 
Dim invPropSet As PropertySet 
invPropSet=invPropSets.Item("Design Tracking Properties") 
Dim invPartNumiProp As Inventor.Property 
invPartNumiProp=invPropSet.Item("Part Number")
Dim sFname As String
sFname=ThisDoc.Path & "\" & invPartNumiProp.Value & ".dwg"
oCompDef.DataIO.WriteDataToFile(sOut, sFname)
oCompDef.FlatPattern.ExitEdit

Thanks for your help.