09-08-2018
12:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-08-2018
12:45 PM
I am doing with save copy as with a rule.
The "Save As" folder resorts to "Projects" despite I assigned different folder path. I saw many help in the forum: they all give the same result. Could someone help me please.
Sub Main() oExit = MessageBox.Show("EXIT?", "Title", MessageBoxButtons.YesNo) If oExit = vbYes Then Exit Sub saveFolderStp = "C:\Roy XX\1551\STP" saveFolderIges = "C:\Roy XX\1551\IGES" oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) Dim FFN_wExt As String FFN_wExt = ThisDrawing.ModelDocument.FullFileName 'specify word splitting characters "space" and "dash" Dim Separators() As Char = {"\"c, "."c} Sentence = FFN_wExt Words = Sentence.Split(Separators) Dim oWords As New ArrayList i = 0 For Each wrd In Words oWords.Add(wrd) i += 1 Next oCount = oWords.Count LFN_woExt = oWords(oCount-2) LFN_revNumber = iProperties.Value("Project", "Revision Number") revNumber_Edit = InputBox("REV. NUMBER (EDIT)", "EDIT", LFN_revNumber) LFN_revNumber = revNumber_Edit LFN_wRev = LFN_woExt & "-" & LFN_revNumber Dim optionsSave As New ArrayList oStp = ".stp" oIges = ".iges" oExit = "EXIT" optionsSave.Add(oStp) optionsSave.Add(oIges) optionsSave.Add(oExit) selectionSave = InputListBox("Prompt", optionsSave, optionsSave(0), Title := "FILE EXPORT", ListName := "List") If selectionSave = oExit Then Exit Sub If selectionSave = oSTP Then strFolder = saveFolderStp If selectionSave = oIgs Then strFolder = saveFolderIges saveCopyAs(FFN_wExt, strFolder, LFN_wRev, selectionSave) End Sub Sub saveCopyAs(FFN_wExt, strFolder, strFile, selectionSave) oFile = ThisApplication.Documents.Open(FFN_wExt, False) 'False/True: open the file is invisibe/visible oDoc = ThisDoc.Document xx = selectionSave Dim oFileDlg As inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) If xx = ".stp" Then oFileDlg.Filter = "STEP Files (*.stp; *.ste; *.step)|*.stp" ' Else If xx = ".ipt" Then' oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"' Else If xx = ".iam" Then' oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"' Else If xx = ".idw" Then' oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw" Else If xx = ".iges" Then oFileDlg.Filter = "IGES Files (*.igs; *.ige; *.iges)|*.iges" End If oFileDlg.InitialDirectory = strFolder 'ThisDoc.WorkspacePath() oFileDlg.FileName = strFile 'iProperties.Value("Project", "Part Number") oFileDlg.CancelError = True On Error Resume Next oFileDlg.ShowSave() If Err.Number <> 0 Then MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled") ElseIf oFileDlg.FileName <> "" Then MyFile = strFolder.FileName 'oFileDlg.FileName oDoc.SaveAs(MyFile, True) 'True = Save As Copy & False = Save As End If oFile.Close End Sub
Solved! Go to Solution.
09-10-2018
12:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-10-2018
12:22 AM
Call ThisApplication.CreateFileDialog(ofiledlg)
path = new path to be placed here
' Set the initial directory that will be displayed in the dialog.
ofiledlg.InitialDirectory = path
09-10-2018
04:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-10-2018
04:10 AM
Hoping that solution provided in below forum link would help.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

09-11-2018
12:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-11-2018
12:41 AM
Thanks. It helped to to get around.
My rule as shown below, works fine.
Sub Main()
oExit = MessageBox.Show("EXIT?", "Title", MessageBoxButtons.YesNo)
If oExit = vbYes Then Exit Sub
saveFolderStp = "C:\Roy XX\1551\STP\"
saveFolderIges = "C:\Roy XX\1551\IGES\"
oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
Dim FFN_wExt As String
FFN_wExt = ThisDrawing.ModelDocument.FullFileName
'specify word splitting characters "space" and "dash"
Dim Separators() As Char = {"\"c, "."c}
Sentence = FFN_wExt
Words = Sentence.Split(Separators)
Dim oWords As New ArrayList
i = 0
For Each wrd In Words
oWords.Add(wrd)
i += 1
Next
oCount = oWords.Count
LFN_woExt = oWords(oCount-2)
LFN_revNumber = iProperties.Value("Project", "Revision Number")
revNumber_Edit = InputBox("REV. NUMBER (EDIT)", "EDIT", LFN_revNumber)
LFN_revNumber = revNumber_Edit
LFN_wRev = LFN_woExt & "-" & LFN_revNumber
Dim optionsSave As New ArrayList
oStp = ".stp"
oIges = ".iges"
oExit = "EXIT"
optionsSave.Add(oStp)
optionsSave.Add(oIges)
optionsSave.Add(oExit)
selectionSave = InputListBox("Prompt", optionsSave, optionsSave(0), Title := "FILE EXPORT", ListName := "List")
If selectionSave = oExit Then Exit Sub
If selectionSave = oSTP Then strFolder = saveFolderStp
If selectionSave = oIgs Then strFolder = saveFolderIges
saveCopyAs(FFN_wExt, strFolder, LFN_wRev, selectionSave)
End Sub
Sub saveCopyAs(FFN_wExt, strFolder, strFile, selectionSave)
'oFile = ThisApplication.Documents.Open(FFN_wExt, True) 'False/True: open the file is invisibe/visible
'MessageBox.Show("strFolder: " & strFolder, "Title")
'MessageBox.Show("strFile: " & strFile, "Title")
oDoc = ThisDoc.Document
xx = selectionSave
Dim oFileDlg As inventor.FileDialog = Nothing
Call ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = strFolder 'ThisDoc.WorkspacePath()
If xx = ".stp" Then
oFileDlg.Filter = "STEP Files (*.stp; *.ste; *.step)|*.stp"
' Else If xx = ".ipt" Then' oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"' Else If xx = ".iam" Then' oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"' Else If xx = ".idw" Then' oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw"
Else If xx = ".iges" Then
oFileDlg.Filter = "IGES Files (*.igs; *.ige; *.iges)|*.iges"
End If
oFileDlg.DialogTitle = "Save Native"
' Call oFileDlg.ShowOpen
oFileDlg.FileName = strFolder & strFile '"C:\Temp\DefaultFileName" 'strFile 'iProperties.Value("Project", "Part Number")
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowSave()
If Err.Number <> 0 Then
MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
ElseIf oFileDlg.FileName <> "" Then
MyFile = strFolder.FileName 'oFileDlg.FileName
oDoc.SaveAs(MyFile, True) 'True = Save As Copy & False = Save As
End If
'oFile.Close
End Sub