Esempio n. 1
0
        /// <summary>
        /// Get all user modifiable parameters in the revit doc.
        /// Only get parameters of string storage types, as there's not much point spell cheking numbers.
        ///
        /// </summary>
        /// <param name="doc">Revit doc to spell check</param>
        /// <returns>parmaeters</returns>
        private List <CorrectionCandidate> GetAllTextParameters(Document doc)
        {
            var candidates = new List <CorrectionCandidate>();
            var collector  = new FilteredElementCollector(doc).WhereElementIsNotElementType();

            // Get TextNote Elements
            candidates.AddRange(GetTextNoteElements(doc));

            foreach (Element element in collector)
            {
                var parameterSet = element.Parameters;
                if (parameterSet == null || parameterSet.IsEmpty)
                {
                    continue;
                }
                foreach (var parameter in parameterSet)
                {
                    if (parameter is Autodesk.Revit.DB.Parameter)
                    {
                        Autodesk.Revit.DB.Parameter p = (Autodesk.Revit.DB.Parameter)parameter;
                        if (p == null || !p.HasValue)
                        {
                            continue;
                        }
                        if (p.IsReadOnly)
                        {
                            continue;
                        }
                        try
                        {
                            if (p.StorageType == StorageType.String)
                            {
                                var rc = new CorrectionCandidate(p, hunspell, ref autoReplacementList);

                                if (!string.IsNullOrEmpty(rc.OriginalText))
                                {
                                    candidates.Add(rc);
                                }
                            }
                        }
                        catch (System.Exception e)
                        {
                            System.Diagnostics.Debug.WriteLine(e.Message);
                        }
                    }
                }
            }
            return(candidates);
        }
Esempio n. 2
0
        private List <CorrectionCandidate> GetTextNoteElements(Document doc)
        {
            var candidates = new List <CorrectionCandidate>();
            FilteredElementCollector collector = new FilteredElementCollector(doc);

            collector.OfCategory(BuiltInCategory.OST_TextNotes);
            foreach (Element element in collector)
            {
                var note = (TextElement)element;
                if (note != null)
                {
                    var cc = new CorrectionCandidate(note, hunspell, ref autoReplacementList);
                    candidates.Add(cc);
                }
            }
            return(candidates);
        }