Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 67020

Sorting Parameters in the Family Editor

$
0
0

I'm trying to sort some parameters in the family editor.  I have a Macro that adds all the parameters in the  shared parameter file to the family.  But the order they appear seems to be alphabetical.  I'd like to specify the order, using the SortParameters.  Possibly by using a list that has the parameter names in the right order. 

 

I've got everything working up until the sorting.  I can't figure out how to get the argument that SortParameters from a list of the parameter names.

 

Here is my code so far.

 

//UIDocument uiDoc = this.ActiveUIDocument;
            Document doc = this.ActiveUIDocument.Document;
            
            // insert the shared parameters from the file into the family document
            Category cat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_LightingFixtures);
            DefinitionFile spFile = this.Application.OpenSharedParameterFile();
            FamilyManager famMan = doc.FamilyManager;
                foreach (DefinitionGroup dG in spFile.Groups)
                    {
                        var v = (from ExternalDefinition d in dG.Definitions select d);
                            
                            using (Transaction t = new Transaction(doc))
                            {
                            t.Start("Add Space Shared Parameters");
                            TaskDialog.Show("Revit""Start");
                            foreach (ExternalDefinition eD in v)
                                {
                                FamilyParameter fp = famMan.AddParameter (eD,BuiltInParameterGroup.PG_TEXT,false);
                                }//end foreach
                            t.Commit();
                            }//end using transaction
                                            
                    }// end foreach
                
                // go through the parameters to display their names and order
                IList<FamilyParameter> familyPar = famMan.GetParameters();
                String strNames = null;
                Dictionary<string, FamilyParameter> sortedPar = new Dictionary<string, FamilyParameter>();
                foreach (FamilyParameter fp in familyPar)
                    {
                    strNames = strNames + fp.Definition.Name.ToString() + "\n";
                    sortedPar.Add(fp.Definition.Name.ToString(), fp);
                    
                    }
                    TaskDialog.Show("Revit", strNames);
                                        
                //start sorting here
                var strings = new List<String> {"TYPE""STYLE""MOUNTING""LENS""LAMP WATTS""LAMP COUNT""LAMP MODEL""TOTAL VA'S"};
                famMan.SortParameters(strings); //this line gives an error, since it wants a "Revit.DB.ParametersOrder"

 

Any help would be appreciated.
                 


Viewing all articles
Browse latest Browse all 67020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>