Export DXF of Flat Pattern from within IDW

Export DXF of Flat Pattern from within IDW

Rich-T
Advocate Advocate
767 Views
4 Replies
Message 1 of 5

Export DXF of Flat Pattern from within IDW

Rich-T
Advocate
Advocate

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.
0 Likes
768 Views
4 Replies
Replies (4)
Message 2 of 5

Rich-T
Advocate
Advocate
Ah, cracked it.
0 Likes
Message 3 of 5

JamesLovell
Advocate
Advocate

Can you enlighten us please?

 

sounds like a useful script 🙂

Regards,

James Lovell
Windows 10 Professional (64-Bit)
AMD Ryzen 9 3900X 12 Core CPU
32GB Corsair VENGEANCE DDR4 3200MHz,QUADRO RTX 4000, 1TB CORSAIR MP600 GEN 4 PCIe NVMe
Product Design & Manufacturing Collection
0 Likes
Message 4 of 5

Rich-T
Advocate
Advocate

The main purpose of this rule was to create a one click export of dxf, stp & pdf (to defined folder locations) of a sheetmetal part from the idw.

I broke it down in to 3 external rules & then wrote a rule to fire them all off together.

 

But the issue i had appears to have been with the line

 

oDoc = ThisDoc.ActiveDocument (see above)

 

I changed it to this (below) and it worked out fine).

 

oDoc = ThisDoc.ModelDocument

 

 

 

Message 5 of 5

lesmfunk
Collaborator
Collaborator

Nice job! dxf's and pdf's are standard for laser shops.

 

I'll have to take another look at your code. I've always ignored the error from the idw, but I didn't care 'cuz I've already dxf'd it from the ipt. I also set the part to "Released" during the operation.

 

There is an idea for publishing pdf files automatically:

 

http://forums.autodesk.com/t5/vault-ideastation/pdf-publishing/idi-p/3509532

 

Vote for it!! Everyone's been coding it for about a decade. It is the top idea in Vault Ideastation.

0 Likes