Ilogic code, export all sheet metal as dxf in folder and write file name on dxf for graving

Ilogic code, export all sheet metal as dxf in folder and write file name on dxf for graving

sebastian_duerrenmatt2TK7V
Explorer Explorer
1,716 Views
23 Replies
Message 1 of 24

Ilogic code, export all sheet metal as dxf in folder and write file name on dxf for graving

sebastian_duerrenmatt2TK7V
Explorer
Explorer

Hi guys,

 

I`m searching desperatly for an Ilogic code to export dxf files from all sheet metal parts in an assembly. I`ve found some codes in the forum but i need in addition that the file name of the sheet metal part gets written on an edge of the dxf sheet metal unwinding. We`re chaning from Autodesk Advance to Inventor in our company.

 

Thanks a lot for your help!

 

In the attachment you`ll find an example from Advance how the exported dxf file should look like. There ist just the positionnumber but the whole file name would be better anyway.

0 Likes
Accepted solutions (1)
1,717 Views
23 Replies
Replies (23)
Message 21 of 24

marcin_otręba
Advisor
Advisor

you can use below code to export to selected folder with part number placed in dxf file:

 

 

Imports System.Windows.Forms
Dim
ass As AssemblyDocument = ThisDoc.Document On Error Resume Next OpenAt = "C:\" ' give your own starting location Dim dialog = New FolderBrowserDialog() ' declare folder picker dialog.SelectedPath = OpenAt ' give starting location If DialogResult.OK = dialog.ShowDialog() Then ' show folder picker and if button "ok was clicked export dxf's to picked location For Each ofile As Document In ass.AllReferencedDocuments dxffilename = "" If ofile.ComponentDefinition.Type = kSheetMetalComponentDefinitionObject Then Dim oSheetMetalCompDef As SheetMetalComponentDefinition = ofile.ComponentDefinition Dim fp As FlatPattern If oSheetMetalCompDef.HasFlatPattern = False Then oSheetMetalCompDef.Unfold oSheetMetalCompDef.FlatPattern.ExitEdit End If fp = oSheetMetalCompDef.FlatPattern nnname = ofile.PropertySets.Item(3).Item("Part Number").Value dxffilename =dialog.SelectedPath & "\" & nnname &".dxf" fp.Edit() Dim oSketch As PlanarSketch Dim oSketches As PlanarSketches Dim oTextBox As Inventor.TextBox oSketches = fp.Sketches Dim oFace As Face = fp.TopFace Dim oTransGeom As TransientGeometry = ThisApplication.TransientGeometry oSketch = oSketches.Add(oFace, False) If oSketch.NaturalAxisDirection = True Then MessageBox.Show(oSketch.NaturalAxisDirection, "Title") oTextBox = oSketch.TextBoxes.AddFitted(oTransGeom.CreatePoint2d(0.5, 1.2), nnname) End If If oSketch.NaturalAxisDirection = False Then oTextBox = oSketch.TextBoxes.AddFitted(oTransGeom.CreatePoint2d(0.5 + 6.4, -1.2), nnname) oTextBox.Rotation = 4 * Math.Atan(1) End If oTextBox.ConvertToGeometry("dim") oSketch.ExitEdit() Dim oDataIO As DataIO = ofile.ComponentDefinition.DataIO Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=R12&SimplifySplines=true&FeatureProfilesUpLayerCOLOR=255;255;0&InvisibleLayers=IV_BEND;IV_BEND_DOWN;IV_TANGENT;IV_ARC_CENTERS;IV_FEATURE_PROFILES_DOWN;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ROLL_TANGENT;IV_ALTREP_BACK;IV_ROLL;" oDataIO.WriteDataToFile(sOut, dxffilename) oSketch.Delete End If Next End If

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 22 of 24

marcin_otręba
Advisor
Advisor

hi @rzsla  i didin't manage to do it because it will consume to much effort. I do not know if it is even possible because you should analyse it line by line if it doesn't interact with anything elese, even if you do it then is some chanse that it will be placed inside some cutout without interation with enything else.

I think that best way it could be to create extrude and check affected features - but it must be done in model space. then you could get some results.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 23 of 24

frank5838S
Contributor
Contributor

Thank you, that worked!

 

For each part I get this message:

frank5838S_0-1740063392593.png

How can I avoid this?

 

0 Likes
Message 24 of 24

marcin_otręba
Advisor
Advisor

remove:

MessageBox.Show(oSketch.NaturalAxisDirection, "Title")

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders