Automating Flat Pattern DXF Export of Parts - almost impossible

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Context:
We are using Inventor Professional 2016.
When a Part file (.ipt) is open you can follow this procedure:
1) right click in the Model tree on "Flat Pattern" and select "SaveCopy As ..."
this opens a "Save Copy As" dialog
2) here you can select Save as type DXF Files(*.dxf) and click Save
this opens a "Flat Pattern DXF Export Options" dialog
3) here you can select various options on three tabs "General", "Layer" and "Geometry"
You can from this dialog save the selected configuration in an .ini file and reload this at a later time.
4) you can also in the "General" tab select to add a "Post Process" DWG/DXF Customize .xml file.
5) When you select "OK" a .dxf file is generated according to the selected configuration.
Problem:
We would like to be able to perfom this operation from code (c# Add-in) using the Inventor API.
From various other post we have understood that the DXF translator can't be used for writing out sheet metal flat pattern as DXF.
This is bad new as we hoped to use the configuration .ini file produced by the manual procedure described above.
This leaves us to use the DataIO method.
The documentation for this method is very sparse and it uses a format that is totally different from the specification in the configration .ini file.
Solution?:
We call the DataIO method:
internal void exportCurrentPartToDxf(Inventor.Document oDoc, string exportPathFileName, string exportCommand) { if (oDoc is PartDocument) { PartDocument partDoc = (PartDocument)oDoc; if (partDoc.ComponentDefinition is SheetMetalComponentDefinition) { SheetMetalComponentDefinition compDef = partDoc.ComponentDefinition as SheetMetalComponentDefinition; if (useDataIo) { DataIO dataIo = compDef.FlatPattern.DataIO; dataIo.WriteDataToFile(exportCommand, exportPathFileName); } } } }
I think we have managed to produce a commandline that matches an inifile from the manual procedure.
Inifile:
[FP EXPORT SELECT OPTIONS] AUTOCAD VERSION=AutoCAD 2004 [FLATPATTERN LAYER OPTIONS] Tangent Lines=IV_TANGENT:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Bend Lines (Front)=IV_BEND:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Bend Lines (Back)=IV_BEND_DOWN:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Tool Centers (Front)=IV_TOOL_CENTER:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Tool Centers (Back)=IV_TOOL_CENTER_DOWN:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Arc Centers=IV_ARC_CENTERS:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Outer Profile=IV_OUTER_PROFILE:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Inner Profile=IV_INTERIOR_PROFILES:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Feature Profile (Front)=IV_FEATURE_PROFILES:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Feature Profile (Back)=IV_FEATURE_PROFILES_DOWN:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Alternate Rep (Front)=IV_ALTREP_FRONT:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Alternate Rep (Back)=IV_ALTREP_BACK:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Unconsumed Sketches=IV_UNCONSUMED_SKETCHES:Visibility=ON;LinePattern=28100;LineWeight=-1,0000;Color=-255,-255,-255; Tangent Roll Lines=IV_ROLL_TANGENT:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; Roll Lines=IV_ROLL:Visibility=ON;LinePattern=28100;LineWeight=0,0500;Color=0,0,0; [FLATPATTERN GEOMETRY OPTIONS] REBASE GEOMETRY=Yes GROUP GEOMETRY=Yes REPLACE SPLINE=Yes SPLINE SIMPLIFICATION METHOD=Linear CHORD_TOLERANCE=0,010 mm TRIM CENTERLINES=Yes
Commandline (one line)
FLAT PATTERN DXF?AcadVersion=2004 &TangentLayer=IV_TANGENT &TangentLayerLineType=37633 &TangentLayerLineWeight=0,0500 &TangentLayerColor=0;0;0 &BendLayer=IV_BEND &BendLayerLineType=37633 &BendLayerLineWeight=0,0500 &BendLayerColor=0;0;0 &BendDownLayer=IV_BEND_DOWN &BendDownLayerLineType=37633 &BendDownLayerLineWeight=0,0500 &BendDownLayerColor=0;0;0 &ToolCenterLayer=IV_TOOL_CENTER &ToolCenterLayerLineType=37633 &ToolCenterLayerLineWeight=0,0500 &ToolCenterLayerColor=0;0;0 &ToolCenterDownLayer=IV_TOOL_CENTER_DOWN &ToolCenterDownLayerLineType=37633 &ToolCenterDownLayerLineWeight=0,0500 &ToolCenterDownLayerColor=0;0;0 &ArcCentersLayer=IV_ARC_CENTERS &ArcCentersLayerLineType=37633 &ArcCentersLayerLineWeight=0,0500 &ArcCentersLayerColor=0;0;0 &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 &FeatureProfilesLayer=IV_FEATURE_PROFILES &FeatureProfilesLayerLineType=37633 &FeatureProfilesLayerLineWeight=0,0500 &FeatureProfilesLayerColor=0;0;0 &FeatureProfilesDownLayer=IV_FEATURE_PROFILES_DOWN &FeatureProfilesDownLayerLineType=37633 &FeatureProfilesDownLayerLineWeight=0,0500 &FeatureProfilesDownLayerColor=0;0;0 &AltRepFrontLayer=IV_ALTREP_FRONT &AltRepFrontLayerLineType=37633 &AltRepFrontLayerLineWeight=0,0500 &AltRepFrontLayerColor=0;0;0 &AltRepBackLayer=IV_ALTREP_BACK &AltRepBackLayerLineType=37633 &AltRepBackLayerLineWeight=0,0500 &AltRepBackLayerColor=0;0;0 &UnconsumedSketchesLayer=IV_UNCONSUMED_SKETCHES &UnconsumedSketchesLayerLineType=37633 &UnconsumedSketchesLayerLineWeight=-1,0000 &UnconsumedSketchesLayerColor=-255;-255;-255 &TangentRollLinesLayer=IV_ROLL_TANGENT &TangentRollLinesLayerLineType=37633 &TangentRollLinesLayerLineWeight=0,0500 &TangentRollLinesLayerColor=0;0;0 &RollLinesLayer=IV_ROLL &RollLinesLayerLineType=37633 &RollLinesLayerLineWeight=0,0500 &RollLinesLayerColor=0;0;0 &RebaseGeometry=True &MergeProfilesIntoPolyline=True &SimplifySplines=True &SplineTolerance=0,010
The information form another post "LineType value for Layers in export flat pattern to dxf" was very helpfull.
Using the LinePattern values from the .ini file produced ugly COM exceptions like:
{System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.DataIO.WriteDataToFile(String Format, String FileName)
The **LineType parameters values must be taken from the API Enum:
LineTypeEnum Enumerator
Name Value Description kChainLineType 37644 Chain line style. kContinuousLineType 37633 Continuous line style. kCustomLineType 37649 Custom line style. kDashDottedLineType 37638 Dash dotted line style. kDashedDoubleDottedLineType 37645 Dashed double dotted line style. kDashedHiddenLineType 37641 Dashed hidden line style. kDashedLineType 37634 Dashed line style. kDashedTripleDottedLineType 37647 Dashed triple dotted line style. kDefaultLineType 37648 default line style. kDottedLineType 37636 Dotted line style. kDoubleDashDoubleDottedLineType 37639 Double dash double dotted line style. kDoubleDashedChainLineType 37637 Double dashed line style. kDoubleDashedDottedLineType 37646 Double dashed dotted line style. kDoubleDashedTripleDottedLineType 37640 Double dash triple dotted line style. kLongDashDottedLineType 37642 Long dash dotted line style. kLongDashedDoubleDottedLineType 37635 Long dashed double dotted line style. kLongDashTripleDottedLineType 37643 Long dash triple dotted line style.
Questions:
Q1)
Can anybody verify that this is the only way to mimic the manual procedure?
Q2)
The "Flat Pattern DXF Export Options" dialog offers a setting called "Trim Centerlines at Contour" - what is the DataIO command param for this?
Q3)
Can anyone give us pointers to documentation for the "Post Process" DWG/DXF Customize .xml file from stetp 4) in the manual process?
Thanks in advance
Lars Lund Hansen