///////////////////////////////////////////////////////////// // Use: Prompts user to locate thread sketch template, if // not found automatically. ///////////////////////////////////////////////////////////// private string GetThreadTemplatePath() { try { string pathInit = Assembly.GetExecutingAssembly().Location; FileInfo fi = new FileInfo(pathInit); Inventor.FileDialog fileDlg = null; _Application.CreateFileDialog(out fileDlg); fileDlg.Filter = "Inventor Parts (*.ipt)|*.ipt"; fileDlg.FilterIndex = 1; fileDlg.DialogTitle = "Select Thread Template"; fileDlg.InitialDirectory = fi.DirectoryName + "\\Thread Templates"; fileDlg.FileName = "BSW Template.ipt"; fileDlg.MultiSelectEnabled = false; fileDlg.OptionsEnabled = false; fileDlg.CancelError = true; fileDlg.SuppressResolutionWarnings = true; fileDlg.ShowOpen(); return(fileDlg.FileName); } catch { return(string.Empty); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Use: Displays Open Dialog and returns filename selected by user // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static string ShowOpenDialog(string title, string filter) { try { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; string pathInit = InvApp.DesignProjectManager.ActiveDesignProject.WorkspacePath; if (pathInit == string.Empty) { pathInit = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Desktop); } System.IO.FileInfo fi = new System.IO.FileInfo(pathInit); Inventor.FileDialog fileDlg = null; InvApp.CreateFileDialog(out fileDlg); fileDlg.Filter = filter; fileDlg.FilterIndex = 1; fileDlg.DialogTitle = title; fileDlg.InitialDirectory = fi.DirectoryName; fileDlg.FileName = ""; fileDlg.MultiSelectEnabled = false; fileDlg.OptionsEnabled = false; fileDlg.CancelError = true; fileDlg.SuppressResolutionWarnings = true; fileDlg.ShowOpen(); return(fileDlg.FileName); } catch { return(string.Empty); } }