DXF export filename without sheet name

DXF export filename without sheet name

josh.linares-stanley
Enthusiast Enthusiast
439 Views
2 Replies
Message 1 of 3

DXF export filename without sheet name

josh.linares-stanley
Enthusiast
Enthusiast

Hi,

I have a script that renames each sheet name to the below format. My issue is that when a drawing is exported to DXF, this sheet name is automatically tagged on to the end of each dxf sheet file name. (Often long descriptions will make the filename too long to open in other programs). 

joshlinaresstanley_0-1652215461046.png 

joshlinaresstanley_2-1652216069984.png

 

Is there a way to revert back to having just the sequential sheet number for the DXF filenames only?

Below is the script I use for exporting to DXF

' Get the DXF translator Add-In.  
Dim DXFAddIn As TranslatorAddIn  
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")  

'Set a reference to the active document (the document to be published).  
Dim oDocument As Document  
oDocument = ThisApplication.ActiveDocument  
Dim oContext As TranslationContext  
oContext = ThisApplication.TransientObjects.CreateTranslationContext  
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism  

' Create a NameValueMap object  
Dim oOptions As NameValueMap  
oOptions = ThisApplication.TransientObjects.CreateNameValueMap  
' Create a DataMedium object  
Dim oDataMedium As DataMedium  
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium  

' Check whether the translator has 'SaveCopyAs' options  
	If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then  
	Dim strIniFile As String  
	strIniFile = "C:\temp\dxfout.ini"  
	' Create the name-value that specifies the ini file to use.  
	oOptions.Value("Export_Acad_IniFile") = strIniFile  
End If  

'Set the destination file name  

Dim IPJ As String
Dim IPJ_Name As String
Dim IPJ_Path As String
Dim FNamePos As Long
IPJ = ThisApplication.FileLocations.FileLocationsFile
FNamePos = InStrRev(IPJ, "\", -1)  
IPJ_Name = Right(IPJ, Len(IPJ) - FNamePos)
IPJ_Folder_Location = Left(IPJ, Len(IPJ) -Len(IPJ_Name))

'Sets the Dirctory that the PDF should be saved in
DXFPath = IPJ_Folder_Location & "DXF" & "\" & ThisDoc.FileName(False) & "-rev" & iProperties.Value("Project", "Revision Number")
DXFName = DXFPath & "\" & ThisDoc.FileName(False) & "-rev" & iProperties.Value("Project", "Revision Number") & ".dxf"

'Set the DXF target file name
oDataMedium.FileName = DXFName
MessageBox.Show(DXFName, "Title")

'Checks to see if that directory exists, if not, it is created
If(Not System.IO.Directory.Exists(DXFPath)) Then
	System.IO.Directory.CreateDirectory(DXFPath)
End If

oDataMedium.FileName = DXFName 'same folder, or uncomment:  
'oDataMedium.FileName = "C:\myDXFfolder\" & ThisDoc.FileName(False) & ".dxf" 'fixed folder  
'Publish document.  
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)  

'Launch the dxf file in whatever application Windows is set to open this document type with  
i = MessageBox.Show("Preview the DXF file?", "Title",MessageBoxButtons.YesNo,MessageBoxIcon.Question)  
If i = vbYes Then ThisDoc.Launch(oDataMedium.FileName)

 

 

0 Likes
440 Views
2 Replies
Replies (2)
Message 2 of 3

dalton98
Collaborator
Collaborator

Edit: Sorry, the code I posted wouldn't work with how you have it set up. You would need to somewhere in your code open up the drawing document and search each sheet until you get a match. It would look something like this:

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.Documents.Open("drawing.idw", True)

oDrawingDoc.Activate()

Dim oSheet As Sheet
Dim oSheetNumber As String
For Each oSheet In oDrawingDoc.Sheets
	If InStrRev(oSheet.Name, iProperties.Value("Project", "Part Number")) > 0
		 oSheetNumber = "Sheet:" & Right(oSheet.Name, 1)
	End If
Next

oDrawingDoc.Close
'your code------------------------ DXFName = DXFPath & "\" & oSheetNumber & "-rev" & iProperties.Value("Project", "Revision Number") & ".dxf"

 

0 Likes
Message 3 of 3

josh.linares-stanley
Enthusiast
Enthusiast

Hi, Thanks for the reponse. I think I have found a work around for this. I've added a subroutine at the start which simply renames each sheet back to "SHT". After the drawing has exported, the document saves which re-executes the "sheet-renamer" script.

 

0 Likes