Export to dxf, in separate folders by thickness

Export to dxf, in separate folders by thickness

kresh.bell
Collaborator Collaborator
1,076 Views
7 Replies
Message 1 of 8

Export to dxf, in separate folders by thickness

kresh.bell
Collaborator
Collaborator

Would anyone know how to edit exist iLogic or do a new one that would be exported to dxf but not all in one folder rather than folders according to the thickness of the material, in one folder all flat pattern of the same thickness

 

 

0 Likes
Accepted solutions (1)
1,077 Views
7 Replies
Replies (7)
Message 2 of 8

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, try this code to run it from an assembly, look for all reference files of sheet metal, export them to dxf without Bend lines or tangent lines. Group the sheets into folders by thickness and material. You can place a revision to your sheetmetals.

Sub Main()
    
    Dim New_Folder_Path As String = ThisDoc.Path
    Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
 
    My.Computer.FileSystem.CreateDirectory(New_Folder_Path)
    
    'Ask user for REV level
    Dim Rev_Level As String = ""
    Rev_Level = InputBox ("Enter Rev Level","Creating DXF files For Entire Assembly")
    
    Dim Count_up As Integer = 0
    Dim Gauge_Folders(12) As String
    Dim Ga As String
    Dim doc As Document
	Dim R_Part As String
	Dim oMaterial As Material
    
    For Each doc In oAsmDoc.AllReferencedDocuments 
        If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 
			Try
				R_Part = doc.DisplayName
				oMaterial = doc.ComponentDefinition.Material
				Gauge_Path = New_Folder_Path & "\" & Parameter(R_Part, "Thickness") & " " & oMaterial.Name
							MessageBox.Show(Gauge_Path )
				Try
					My.Computer.FileSystem.CreateDirectory(Gauge_Path)						
				Catch
				End Try
            	Call Make_DXF(doc, Rev_Level, Gauge_Path)		
			Catch
			End Try		
		End If
    Next 
MsgBox("DXF Export Complete",,"All Done")		
    
End Sub
    
Sub Make_DXF(oDoc As Document, Rev_L As String, File_Location As String)

	ThisApplication.Documents.Open(oDoc.FullFileName, True)
		
	Dim Part_Name As String = oDoc.DisplayName
	Dim TestPos As Integer = 0

	Dim Rev_Adder As String = ""
	If Rev_L <> "" Then Rev_Adder = " REV " & Rev_L

	TestPos = InStr(1, Part_Name, ".")

	If TestPos <> 0 Then Part_Name = Left(Part_Name, InStr(Part_Name, ".")-1)

	Dim New_Name As String = Part_Name 

	Dim oFilename As String  = File_Location & "\" & New_Name & Rev_Adder & ".dxf"

	Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition

	If oCompDef.HasFlatPattern = False Then 
		oCompDef.Unfold
	Else
		oCompDef.FlatPattern.Edit
	End If

	Dim oFlatPattern As FlatPattern = oCompDef.FlatPattern
	Dim oFace As Face = oFlatPattern.TopFace

	Dim oCommand As CommandManager = ThisApplication.CommandManager

	oCommand.DoSelect(oFace)
	oCommand.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent,oFilename) 
	oCommand.ControlDefinitions.Item("GeomToDXFCommand").Execute2(True)

	oCompDef.FlatPattern.ExitEdit
	oDoc.Close

End Sub

 I hope this helps your work. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 8

kresh.bell
Collaborator
Collaborator

Hi Sergio,

sorry for delay, very very good, really great, thank you very much, it is extremely good and useful iLogic

Message 4 of 8

Moverano
Advocate
Advocate
Hello,
How could the code be tweaked so that it does not have to be accepted for each piece?
great job
0 Likes
Message 5 of 8

ersin_karacoban
Participant
Participant

I would like to write the number of pieces next to the exported DXF file. Can you help me with this?

For example; 2103 02 04 - 16 QTY

 

 

0 Likes
Message 6 of 8

DeptaM
Enthusiast
Enthusiast

Good day,
where are dxf files saved?
Thank you

0 Likes
Message 7 of 8

ersin_karacoban
Participant
Participant

It extracts to the folder with the assembly file.

0 Likes
Message 8 of 8

DeptaM
Enthusiast
Enthusiast

Good day,
everything goes but no .dxf file is exported. I have Inventor 2023

DeptaM_1-1692860803613.png

DeptaM_2-1692860829177.png

 

 

 

0 Likes