Example #1
0
        private string suggestModelName()
        {
            Autodesk.Revit.DB.Document doc = cbSelectedModel.SelectedItem as Autodesk.Revit.DB.Document;

            if (doc != null)
            {
                string filename = Path.GetFileNameWithoutExtension(doc.PathName);
                if (doc.IsWorkshared && (!doc.IsDetached))
                {
                    try
                    {
                        var    mp          = doc.GetWorksharingCentralModelPath();
                        string centralPath = Autodesk.Revit.DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(mp);
                        if ((mp.ServerPath == false) && System.IO.Path.IsPathRooted(centralPath))
                        {
                            string folder   = Path.GetDirectoryName(centralPath);
                            string baseName = Path.GetFileNameWithoutExtension(centralPath);
                            filename = Path.Combine(folder, "Snapshots", baseName + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb");
                        }
                    }
                    catch { }
                }
                else
                {
                    filename = Path.Combine(Path.GetDirectoryName(doc.PathName), filename + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb");
                }



                return(filename);
            }

            return(string.Empty);
        }
Example #2
0
        private string suggestModelName()
        {
            Autodesk.Revit.DB.Document doc = cbSelectedModel.SelectedItem as Autodesk.Revit.DB.Document;

            if (doc != null)
            {
                string filename = Path.GetFileNameWithoutExtension(doc.PathName);
                if (doc.IsWorkshared && (!doc.IsDetached))
                {
                    try
                    {
                        var    mp          = doc.GetWorksharingCentralModelPath();
                        string centralPath = Autodesk.Revit.DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(mp);
                        if ((mp.ServerPath == false) && System.IO.Path.IsPathRooted(centralPath))
                        {
                            string folder   = Path.GetDirectoryName(centralPath);
                            string baseName = Path.GetFileNameWithoutExtension(centralPath);
                            filename = Path.Combine(folder, "Snapshots", baseName + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb");
                        }
                        if (centralPath.ToUpper().StartsWith("BIM360:"))
                        {
                            filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), filename + ".sdb");
                        }
                    }
                    catch { }
                }
                else
                {
                    if (String.IsNullOrEmpty(doc.PathName))
                    {
                        return(String.Empty);
                    }

                    try
                    {
                        filename = Path.Combine(Path.GetDirectoryName(doc.PathName), filename + "_" + DateTime.Now.ToString("yyyyMMdd_hhmm") + ".sdb");
                    }
                    catch (Exception ex)
                    {
                        doc.Application.WriteJournalComment("Note: struggling to get suggested filename: " + ex.GetType().Name + ": " + ex.Message, false);
                    }
                }



                return(filename);
            }

            return(string.Empty);
        }