Over time I added features to this code that are not mentioned here in this thread. What I am posting below is a version of the code that I just simplified for you. This will work for both part files and assemblies. First thing it does is save what you are working on. Then it will ask if you want to run the rule, then ask for a revision level(you can leave that blank-just hit OK), then confirm the path for you before creating the dxf files. It will delete any previous DXFs for each file and add the material gauge to the start of the file name for sorting purposes.
Before I post the code let me answer your second question. In order to have the rules available to all of your files you need to set up external rules. To do that open iLogic Configuration:

and then add a new External Rule Directory:

Once you have done that you will see the folder show up under external rules. Any rules you create in there will be available from all of your files. If you have other users you can put that folder on a server drive and map the external directory to the same folder on the other computers. Mine looks like this:

Here is the code, note the one place you will need to update the path if you want to change it is right after Gauge_Path =
Sub Main()
ThisApplication.[_LibraryDocumentModifiable] = True
Dim oDoc As Document
Dim Job_confirm As String
Dim oAsmDoc As AssemblyDocument
Dim Rev_Level As String = ""
Dim New_Folder_Path As String
Dim Ga As String
Dim JobNum As String = iProperties.Value("Project", "Project")
Dim DXFPath As String
Dim Purchased As Boolean = False
Dim Gauge_Path As String
'AutoSave before rule changes anything
Try
SaveMe = ThisDoc.Document
SaveMe.Save
Catch
SaveQ=MsgBox("Save did NOT happen. Do you want to run the rule anyway?",vbYesNo,"Something Went Wrong")
If SaveQ=7 Then Exit Sub
End Try
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'^^^^EDIT PATH BELOW^^^^^^^^^^^^^^
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gauge_Path = "C:\DXF\"
oDoc = ThisDoc.Document
If oDoc.DocumentType = kPartDocumentObject Then
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CODE FOR PART DXF - NOT ASSEMBLY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Job_confirm = MsgBox ("Sending File to DXF Folder " & Gauge_Path, vbOKCancel, "Confirm Path")
If Job_confirm = "2" Then Exit Sub
Rev_Level = InputBox("Enter Rev Level", "Creating DXF file for Single Part")
'ThisApplication.ActiveDocument.BOMSTRUCTURE
Dim oPrtCompDef As PartComponentDefinition
oPrtCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'MsgBox(oPrtCompDef.BOMStructure)
'Exit Sub
Dim oSheetMetalCompDef As SheetMetalComponentDefinition
'set it to the current document
oSheetMetalCompDef = oDoc.ComponentDefinition
'Dim oStyle As SheetMetalStyle
Ga = oSheetMetalCompDef.ActiveSheetMetalStyle.Name
'remove quotes and replace / in fractions with _
Ga = Replace(Ga, "/", "_")
Ga = Replace(Ga, Chr(34), "")
Job_confirm = MsgBox ("Sending File to DXF Folder " & Gauge_Path ,vbOKCancel, "Confirm Path")
'MsgBox(Len(Gauge_Path))
If Job_confirm = "2" Then Exit Sub
Try
My.Computer.FileSystem.CreateDirectory(Gauge_Path)
Call Make_DXF(oDoc, Rev_Level, Gauge_Path)
Catch
MsgBox(Gauge_Path,,"Can't create folder:")
End Try
End If
MsgBox("DXF Export Complete",,"All Done")
Exit Sub 'stop code after part level export
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END CODE FOR PART DXF - NOT ASSEMBLY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ElseIf oDoc.DocumentType = kAssemblyDocumentObject Then
'Correct doc type - now move on
ElseIf oDoc.DocumentType = kDrawingDocumentObject Then
MsgBox("This is Not the Correct Rule",,"Ending Run")
Exit Sub
End If
'Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
Dim doc As Document
Job_confirm = MsgBox ("Sending Files to DXF Folder " & Gauge_Path, vbOKCancel, "Confirm Path")
'MsgBox(Job_confirm,,"job_confirm")
If Job_confirm = "2" Then Exit Sub
'Ask user for REV level
Rev_Level = InputBox ("Enter Rev Level","Creating DXF files For Entire Assembly")
Dim Count_up As Integer = 0
Dim Gauge_Folders(40) As String
Count_up = 0
'Now we loop through all of the parts checking for sheetmetal parts and creating DXF files
'oAsmDoc = ThisApplication.ActiveDocument
For Each doc In oAsmDoc.AllReferencedDocuments
Try
If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Call Make_DXF(doc, Rev_Level, Gauge_Path)
End If
Count_up = Count_up + 1
Catch
MsgBox(doc.FullDocumentName)
End Try
Next
MsgBox("DXF Export Complete",,"All Done")
End Sub
Sub Make_DXF(doc As Document, Rev_L As String, File_Location As String)
'''-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF
'''-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF
'''-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF-----MAKE DXF
Dim oSheetMetalCompDef As SheetMetalComponentDefinition
'set it to the current document
oSheetMetalCompDef = doc.ComponentDefinition
'Dim oStyle As SheetMetalStyle
Dim GA_Adder As String = oSheetMetalCompDef.ActiveSheetMetalStyle.Name
'Dim GA_Adder As String = iProperties.Value(doc.DisplayName, "Custom", "GAUGE")
GA_Adder = Replace(GA_Adder, "/", "_")
GA_Adder = Replace(GA_Adder, Chr(34), "")
GA_Adder = Replace(GA_Adder, "%", "")
GA_Adder = Replace(GA_Adder, ".", "")
Dim Part_Name As String = doc.DisplayName
Dim TestPos As Integer = 0
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = doc.ComponentDefinition
'checking for parts that don't have flat pattern and telling user what parts are skipped for lack of flat pattern
If oCompDef.HasFlatPattern = False Then
MsgBox ("Skipping DXF file for:" & vbNewLine & vbNewLine & Part_Name, ,"Flat Pattern Missing")
Else
'Checking to be sure the name passed to sub has a . in it
TestPos = InStr(1, Part_Name, ".")
'trimming everything before the .
If TestPos <> 0 Then Part_Name = Left(Part_Name, InStr(Part_Name, ".")-1)
Dim New_Name As String = Part_Name
'' '*******************remove line below to remove gauge from file name***********
Part_Name = GA_Adder & " " & Part_Name
'' '*******************remove line above to remove gauge from file name***********
'Creating Rev add-on for file name if needed
Dim Rev_Adder As String = ""
If Rev_L <> "" Then Rev_Adder = " REV " & Rev_L
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^CHECKING FOR AND DELETING OLD DXF FILES^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dim Old_Files As String = ""
'Dim Delete_List(5) As String
'Dim q As Integer = 0
Old_Files = Dir(File_Location & "\" & Part_Name & "*")
Do Until Old_Files = ""
Try
Kill(File_Location & "\" & Old_Files)
Catch
MsgBox("Could Not Delete:" & vbNewLine & vbNewLine & File_Location & "\" & Old_Files,,"Delete Error")
End Try
Old_Files = Dir()
Loop
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^END CHECKING FOR AND DELETING OLD DXF FILES^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dim nameandpath As String = File_Location & "\" & Part_Name & Rev_Adder & ".dxf"
nameandpath = File_Location & "\" & Part_Name & Rev_Adder & ".dxf"
'MsgBox(nameandpath)
Dim oDataIO As DataIO = doc.ComponentDefinition.DataIO
'Create the DXF file now!
Try
oDataIO.WriteDataToFile("FLAT PATTERN DXF?AcadVersion=R12&RebaseGeometry=True&SimplifySpline=True&InteriorProfilesLayer=IV_INTERIOR_PROFILES&InvisibleLayers=IV_TANGENT;IV_BEND;IV_BEND_DOWN;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL&SplineToleranceDouble=0.01",nameandpath)
Catch
MsgBox (nameandpath,,"Error on this file")
End Try
End If
End Sub