Export Sheet Metal Flat Pattern to DWG with options.

Export Sheet Metal Flat Pattern to DWG with options.

philip1009
Advisor Advisor
1,509 Views
1 Reply
Message 1 of 2

Export Sheet Metal Flat Pattern to DWG with options.

philip1009
Advisor
Advisor

I already have an almost working code to automatically export sheet metal flat patterns to a DWG from the ipt.  I'll be using this with other code in the future.  The code does the correct file format, the correct autocad version, and the layer options correctly.  but it won't take the selections for the other options typically found under the geometry tab of the export options.

 

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" _
+"&USE CUSTOMISE=No" _
+"&CUSTOMIZE FILE=c:\program files\autodesk\inventor 2016\Design Data\DWG-DXF\FlatPattern.xml" _
+"&BendLines(Front)=IV_BEND;Visibility=On;LineTypeEnum=28100;LineWeight=0.0500;Color=0,0,0" _
+"&BendLines(Back)=IV_BEND_DOWN;&Visibility=On;&LineTypeEnum=28100;&LineWeight=0.0500;&Color=0,0,0" _
+"&OuterProfile=IV_OUTER_PROFILE;&Visibility=On;&LineTypeEnum=28100;&LineWeight=0.0500;&Color=0,0,0" _
+"&InnerProfile=IV_INTERIOR_PROFILES;&Visibility=On;&LineTypeEnum=28100;&LineWeight=0.0500;&Color=0,0,0" _
+"&FeatureProfile(Front)=IV_FEATURE_PROFILES;&Visibility=On;&LineTypeEnum=28100;&LineWeight=0.0500;&Color=0,0,0" _
+"&FeatureProfile(Back)=IV_FEATURE_PROFILES_DOWN;&Visibility=On;&LineTypeEnum=28100;&LineWeight=0.0500;&Color=0,0,0" _
+"&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" _
+"REBASE GEOMETRY=No" _
+"MERGE PROFILES=Yes" _
+"REPLACE SPLINE=Yes" _
+"SPLINE SIMPLIFICATION METHOD=Linear" _
+"LINEAR TOLERANCE=0.010" _
+"TRIM CENTERLINES=Yes"
Dim sFname As String
sFname = oDoc.FullFileName
sFname = Left$(sFname, Len(sFname) - 3) & "dwg"
oCompDef.DataIO.WriteDataToFile( sOut, sFname)

Like I said, everything else is working fine, it's just the options from REBASE GEOMETRY to TRIM CENTERLINES not being used in the exported file.  Do I have these options named correctly?  Or do I have to use something other than "=Yes" or "=No" statements?

 

Thanks so much in advance, I've been spending days to get this right, and this will be a huge time-saver in the future.

 

P.S. If you want to use this code for DXF export, all you have to do is replace the DWG/dwg references to DXF/dxf, and it will work fine for that too, once I get these option issues worked out.

0 Likes
Accepted solutions (1)
1,510 Views
1 Reply
Reply (1)
Message 2 of 2

philip1009
Advisor
Advisor
Accepted solution

I perused the help files and found that I had the names of the options wrong and the statements wrong.  I also learned that since the visible layer options were the default ones they could be removed.

 

Here's the code to export sheet metal flat pattern from your ipt with the same file name as the ipt and in the same folder:

 

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 sFname As String
sFname=oDoc.FullFileName
sFname=Left$(sFname,Len(sFname)-3)&"dwg"
oCompDef.DataIO.WriteDataToFile(sOut,sFname)

P.S. Again, if you wish to use this to export in a dxf format, just change the translator reference in sOut and sFname to DXF/dxf. 

0 Likes