Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have located two pieces of code that I need to merge into one if anyone is willing to provide some assistance.
I am trying to Export to a ".stp" from an ".idw" but I need the user to be able to choose the location of the exported file.
The code I have found exports to .stp perfectly but to a defined location, in this case "C:\TEMP" , I need it to follow the location as defined by a piece of code meant to export to a .pdf
Is there anyway to merge the .pdf location portion to the .stp file type code?
Here's the two pieces of code:
.pdf location
' Get current location of this file Dim ExportPath As String = ThisDoc.Path ' Check that this file has been saved and actually exists on disk If String.IsNullOrEmpty(ExportPath) Then MsgBox("This file has not yet been saved and doesn't exist on disk!" _ & vbLf & "Please save it first",64, "Lord iLogic") Return End If ' Define folder browse dialog Dim Dialog = New FolderBrowserDialog() ' Set options for folder browser dialog Dialog.SelectedPath = ExportPath Dialog.ShowNewFolderButton = True Dialog.Description = "Choose Folder for Export..." ' Show dialog box If DialogResult.OK = Dialog.ShowDialog() Then ' User clicked 'ok' on dialog box - capture the export path ExportPath = Dialog.SelectedPath & "\" Else ' User clicked 'cancel' on dialog box - exit Return End If oFileName = iProperties.Value("Custom", "Drawing Number") ' Define the filename of the file to be exported ' In this Case it Is a PDF file extension ExportFilename = oFileName & ".pdf" oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'set PDF Options oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'Set the PDF target file name oDataMedium.FileName = ExportPath & ExportFilename Try 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Catch MessageBox.Show("Error writing out PDF", "iLogic") bError = True End Try If bError <> True Then 'Ask user If they want To open (launch) the file we just exported... oMessage = "File exported: " & _ ExportPath & ExportFilename & vbLf & vbLf & _ "Do you want to open the PDF Now?" oQuestion = MessageBox.Show(oMessage, _ "Formsprag iLogic - File Exported",MessageBoxButtons.YesNo) If oQuestion = vbYes Then ThisDoc.Launch(ExportPath & ExportFilename) End If End If
.stp code
'Dim statement: Declares and allocates storage space for variables Dim oPart As Inventor.PartDocument 'Takes the part shown in the 1st view 'of the current sheet's DrawingViews collection oDrawingDoc = ThisDrawing.Document oSheet = ActiveSheet.Sheet oDrawingView = oSheet.DrawingViews.Item(1) oPart = ActiveSheet.View(oDrawingView.Name).ModelDocument ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap oStepFileName = iProperties.Value("Project", "Part Number") & " " & iProperties.Value("Project", "Description") If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then ' Set application protocol. ' 2 = AP 203 - Configuration Controlled Design ' 3 = AP 214 - Automotive Design oOptions.Value("ApplicationProtocolType") = 3 ' Other options... 'oOptions.Value("Author") = "" 'oOptions.Value("Authorization") = "" 'oOptions.Value("Description") = "" 'oOptions.Value("Organization") = "" oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium strFolder = "C:\TEMP\" oData.FileName = strFolder & "\" & oStepFileName & ".stp" oSTEPTranslator.SaveCopyAs(oPart, oContext, oOptions, oData) End If
Solved! Go to Solution.