Results 1 to 3 of 3

Thread: How to retrieve Parameter Value of a Family Element ?

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2015-08
    Posts
    1
    Login to Give a bone
    0

    Default How to retrieve Parameter Value of a Family Element ?

    I have been try to get the parameter value of family

    public class Trial : IExternalCommand
    {
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
    UIApplication uiApp = commandData.Application;
    Document doc = uiApp.ActiveUIDocument.Document;

    ElementCategoryFilter Family = new ElementCategoryFilter(BuiltInCategory.OST_StructuralFoundation);
    FilteredElementCollector collector = new FilteredElementCollector(doc);
    IList<Element> Familylist = collector.WherePasses(Family).ToElements();
    String prompt = "The Precast Element in the current document are:\n";
    foreach (Element e in Familylist)
    {
    Parameter p = e.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM);
    string levelshow = string.Format("Base Level", p.AsValueString());

    prompt += levelshow + "\n";

    }
    TaskDialog.Show("Revit",prompt);
    return Result.Succeeded;
    }

    }

    when i run this add-ins in revit, it doesn't work。 But i cant spot any problem

  2. #2
    Super Moderator david_peterson's Avatar
    Join Date
    2002-09
    Location
    Madison, WI
    Posts
    5,687
    Login to Give a bone
    0

    Default Re: How to retrieve Parameter Value of a Family Element ?

    Not an API solution, but I've used an Add-In Schedule creator that you can get to return basically any object parameter via a schedule.

  3. #3
    100 Club
    Join Date
    2004-09
    Posts
    104
    Login to Give a bone
    0

    Default Re: How to retrieve Parameter Value of a Family Element ?

    When you filter for elements by Built-In Category, you get Elements and ElementTypes of the category. If you then try to get an instance-based parameter (like "Base Level") the types don't have it, and your code fails.

    Try changing this line:

    IList<Element> Familylist = collector.WherePasses(Family).ToElements();

    To:

    IList<Element> Familylist = collector.WherePasses(Family).WhereElementIsNotElementType().ToElements();

Similar Threads

  1. Replies: 1
    Last Post: 2014-11-13, 06:20 PM
  2. Replies: 8
    Last Post: 2013-11-27, 09:07 AM
  3. Replies: 2
    Last Post: 2013-05-21, 06:47 PM
  4. Element ID as parameter
    By mui in forum Revit Architecture - General
    Replies: 0
    Last Post: 2011-10-14, 12:26 AM
  5. Join a family element to a non-family element
    By adnama in forum Revit Architecture - Families
    Replies: 6
    Last Post: 2009-11-08, 08:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •