So, I've changed tack a little in my pursuit of a SUFFIX.
I have found this code (below) which saves out the active sheet of the drawing out as a DXF file with the correct file name. YAY!!
'Make sure the active document is a drawing document.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("This Rule " & iLogicVb.RuleName & " only works on Drawing Documents. Exiting.", vbOKOnly + vbCritical, "WRONG DOCUMENT TYPE")
Return
End If
'Capture the active drawing document, and its active sheet. (make sure the active sheet is the one you want to copy.)
Dim oDDoc As DrawingDocument = ThisDrawing.Document
oSheets = oDDoc.Sheets
Dim oSheet As Sheet = oDDoc.ActiveSheet
'For Each oSheet In oSheets
' oSheet.Activate
'Create the temporary drawing file, copy the sheet, then delete all sheets in new drawing.
Dim oTempDDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, , False)
Dim oTempSheet As Sheet = oSheet.CopyTo(oTempDDoc)
For Each oTSheet As Sheet In oTempDDoc.Sheets
If oTSheet IsNot oTempSheet Then
oTSheet.Delete
End If
Next
'Get the DXF Translator AddIn
Dim oDXF_AddIn As TranslatorAddIn
For Each oAddIn As ApplicationAddIn In ThisApplication.ApplicationAddIns
If oAddIn.DisplayName = "Translator: DXF" Then
oDXF_AddIn = oAddIn
End If
Next
Dim oTO As TransientObjects = ThisApplication.TransientObjects
Dim oContext As TranslationContext = oTO.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As NameValueMap = oTO.CreateNameValueMap
Dim oDataMedium As DataMedium = oTO.CreateDataMedium
Dim oPath As String = IO.Path.GetDirectoryName(oDDoc.FullFileName)
Dim oFName As String = IO.Path.GetFileNameWithoutExtension(ActiveSheet.Sheet.Name)
MessageBox.Show("Sheet Name - " & oFName, "Sheet Name!!")
oDataMedium.FileName = oPath & "\" & oFName & "_DXF.dxf"
MessageBox.Show("FILENAME - " & oFName, "Filename!!")
If oDXF_AddIn.HasSaveCopyAsOptions(oTempDDoc, oContext, oOptions) Then
'If your export DXF settings are saved somewhere else or named differently, you will have to change this next line.
oOptions.Value("Export_Acad_IniFile") = "C:\Users\Darren Lees\Desktop\DXF TEST\DXG-DXF\2010 DXF File.ini"
End If
'Check to see if the DXF already exists, if it does, ask if you want to over write existing file or not.
If System.IO.File.Exists(oDataMedium.FileName) = True Then
oAnswer = MsgBox("A DXF file with this name already exists." & vbCrLf & "Do you want to over write it with this new one?", vbYesNo + vbQuestion + vbDefaultButton2, "DXF ALREADY EXISTS")
If oAnswer = vbNo Then Return
End If
'Publish DXF
oDXF_AddIn.SaveCopyAs(oTempDDoc, oContext, oOptions, oDataMedium)
oTempDDoc.Close(True)
However, this only acts on the currently active sheet. This means I need to change to the next sheet and run the code again to get the next sheet, etc. We occasionally have drawings with 40-50+ sheets and this would get quite tedious and time consuming to continually run the rule for every sheet.
Therefore, I enclosde the relevant code inside a for-next loop in an attempt to iterate through the sheets and have it saved with the relevant title.
It didn't end well!!
I had numerous "variable 'example' hides a variable in an enclosing block" when I save/run the code.
I have a little idea about 'variable sccope', but absolutely not enough to get around this.
I don't know which way to turn, but being so close I'm hoping someone can help??.....please!!
I can supply files if required, but in this case I don't believe it'd help as I'm only focusing on the SHEET NAME for my DXF file title. Therefore, the sheet name can be changed to whatever is required.