Message 1 of 5
Export DXF of Flat Pattern from within IDW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write a rule that will export a dxf of a sheet metal part from within the IDW. I've got code that work within the part file (.ipt) but when i try the run this rule from another rule in the IDW it falls over. The same same code works fine when exporting a STP of the part from the IDW so I think its something to do with the dxf export but can't figure it out. I'm using IV2014.
This rule exports the dxf...(rule is called "DXF")
SyntaxEditor Code Snippet
oPath = ThisDoc.Path oRevNum = iProperties.Value("Project", "Revision Number") PARTNUMBER = iProperties.Value("Project", "Part Number") 'get DXF target folder path oFolder = oPath Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef = oDoc.ComponentDefinition If oCompDef.HasFlatPattern = False Then oCompDef.Unfold Else oCompDef.FlatPattern.Edit End If Dim sOut As String If ExportInner = True Then sOut = "FLAT PATTERN DWG?AcadVersion=2000&OuterProfileLayer=Burn&InteriorProfilesLayer=Burn&InvisibleLayers=IV_UNCONSUMEND_SKETCHES;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_ARC_CENTERS;IV_TOOL_CENTER_DOWN;IV_TOOL_CENTER;IV_ARC_CENTERS;IV_TANGENT;IV_BEND;IV_BEND_DOWN&SplineTolerance Double 0.01" Else sOut = "FLAT PATTERN DWG?AcadVersion=2000&OuterProfileLayer=Burn&InteriorProfilesLayer=Burn&InvisibleLayers=IV_UNCONSUMEND_SKETCHES;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_ARC_CENTERS;IV_TOOL_CENTER_DOWN;IV_TOOL_CENTER;IV_ARC_CENTERS;IV_TANGENT;IV_BEND;IV_BEND_DOWN&SplineTolerance Double 0.01" End If 'Check for the DXF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Get document's full file name Dim sFname As String sFname = ThisDoc.FileName(False) 'without extension 'The file format will depend on the extension'Set file name extension to ".DXF" 'sFname = oPath & "\" & sFname & oRevNum & ".dxf" sFname = oPath & "\" & PARTNUMBER & "_" & oRevNum & ".dxf" oCompDef.DataIO.WriteDataToFile (sOut, sFname)
and this rule runs the dxf rule in the ipt from within the idw...
SyntaxEditor Code Snippet
Dim iLogicAuto As Object = iLogicVb.Automation If (iLogicAuto Is Nothing) Then Exit Sub Dim doc As Document = ThisDrawing.ModelDocument Dim ruleName As String = "DXF" Dim rule As Object = iLogicAuto.GetRule(doc, ruleName) 'get the rule Dim i As Integer = iLogicAuto.RunRuleDirect(rule) 'run the rule
Any help would be greatly appreciated.