Get parameter value in family document

Get parameter value in family document

tdaniel
Contributor Contributor
7,407 Views
1 Reply
Message 1 of 2

Get parameter value in family document

tdaniel
Contributor
Contributor

I am a noob using the following code to get all parameters in my family document in Revit 2015.  I cannot find a way to get the actual value of the parameters.  Hope this is easy and that I'm overlooking something.  My ultimate goal is to search for a few specific family/shared parameters and return their values.  Any help would be greatly appreciated!

 

Document doc = this.ActiveUIDocument.Document;

            FamilyManager famMgr = doc.FamilyManager;
            foreach(FamilyParameter fp in famMgr.Parameters)
            {
               StringBuilder paramInfo = new StringBuilder();
               bool isShared = false;
               
               try
               {
                  Guid paramGuid = fp.GUID;
                  // following line will be reached only when parameter is shared parameter
                  isShared = true;
               }
               catch (Autodesk.Revit.Exceptions.InvalidOperationException)
               {
                  // This exception will be thrown when the parameter is not a shared parameter.
                  isShared = false;
               }
               paramInfo.Append("Name: " + fp.Definition.Name + "; ");
               paramInfo.Append("Is Shared: " + isShared + "; ");
               paramInfo.Append("Is Instance: " + fp.IsInstance + "; ");
               paramInfo.Append("Value:  ");
               Trace.WriteLine(paramInfo.ToString());
               TaskDialog.Show("Parameter Info",  paramInfo.ToString());
               
            }

Accepted solutions (1)
7,408 Views
1 Reply
Reply (1)
Message 2 of 2

tdaniel
Contributor
Contributor
Accepted solution

found this code after posting the question!  Thanks Jeremy!

 

http://thebuildingcoder.typepad.com/blog/2009/11/family-parameter-value.html