BIMSource.SPWriter.ParameterAssigner.LoadSharedParameterFile C# (CSharp) Method

LoadSharedParameterFile() public method

public LoadSharedParameterFile ( ) : bool
return bool
        public bool LoadSharedParameterFile()
        {
            string myDocsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
              OpenFileDialog ofd = new OpenFileDialog();

              ofd.InitialDirectory = myDocsFolder;
              ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
              ofd.FilterIndex = 1;
              ofd.RestoreDirectory = true;
              ofd.Title = "Please Select the Shared Parameter File";

              if (ofd.ShowDialog() == DialogResult.OK)
              {
            m_sharedFilePath = ofd.FileName;
            if (!File.Exists(m_sharedFilePath))
            {
              return true;
            }

            m_app.SharedParametersFilename = m_sharedFilePath;
            try
            {
              m_sharedFile = m_app.OpenSharedParameterFile();
            }
            catch (System.Exception e)
            {
              MessageBox.Show(e.Message);
              return false;
            }
            return true;
              }
              else
              {
            return false;
              }
        }

Usage Example

Example #1
0
        private bool AddParameters()
        {
            Document doc = m_app.ActiveUIDocument.Document;

            if (null == doc)
            {
                MessageBox.Show("There's no available document.");
                return(false);
            }

            if (!doc.IsFamilyDocument)
            {
                MessageBox.Show("The active document is not a family document.");
                return(false);
            }

            ParameterAssigner pa = new ParameterAssigner(m_app.Application, doc);
            // the parameters to be added are defined and recorded in a text file, read them from that file and load to memory
            bool succeeded = pa.LoadSharedParameterFile();

            if (!succeeded)
            {
                return(false);
            }

            Transaction t = new Transaction(doc, "Bind Shared Parameters");

            t.Start();
            succeeded = pa.BindSharedParameters();
            if (succeeded)
            {
                t.Commit();
                return(true);
            }
            else
            {
                t.RollBack();
                return(false);
            }
        }
All Usage Examples Of BIMSource.SPWriter.ParameterAssigner::LoadSharedParameterFile