Announcement

Collapse
No announcement yet.

Shared Parameters Access via API.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Shared Parameters Access via API.

    Again, I'm a noob.

    Our project has a shared parameter "Ceres ID Tag" defined for a certain FamilyType of doors.

    I am filtering on OST_Doors, converting it ToElements().

    I am iterating through the collection and trying to evaluate the value of the Ceres ID Tag (value=10) for the particular door that I am interested in.
    When I iterate through the parameters collection for the particular door that does have a Ceres ID Tag assigned to the shared parameter, I do not see Ceres ID Tag in the parameters.

    I have been unable to find any code demonstrating how to do this.

    Code follows:
    private string ListElements(ExternalCommandData commandData)
    {
    UIDocument uiDoc = commandData.Application.ActiveUIDocument;
    Document document = uiDoc.Document;

    // Create a Filter to get all the doors in the document
    ElementClassFilter familyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));

    ElementCategoryFilter doorsCategoryfilter =
    new ElementCategoryFilter(BuiltInCategory.OST_Doors);
    LogicalAndFilter doorInstancesFilter =
    new LogicalAndFilter(familyInstanceFilter, doorsCategoryfilter);
    FilteredElementCollector collector = new FilteredElementCollector(document);
    ICollection<Element> doors = collector.WherePasses(doorInstancesFilter).ToEleme nts();

    String prompt = "The ids of the doors in the current document are:";
    foreach (Element door in doors)
    {
    prompt += "\n\t" + door.Id.IntegerValue + ": " + door.Name;

    if (door.Id.IntegerValue == 196468)
    {
    foreach (Parameter parm in door.Parameters)
    {
    prompt += "\n " + parm.Definition.Name + ":" + parm.AsValueString();
    }
    }
    }

    return prompt;
    }

    #2
    And, the answer is:

    if (door.Id.IntegerValue == 196468)
    {
    ElementId id = door.GetTypeId();
    ElementType doorType = document.get_Element(id) as ElementType;

    foreach (Parameter parm in doorType.Parameters)
    {
    prompt += "\n " + parm.Definition.Name + ": val: " + parm.AsString();
    }
    prompt += "\n**********************************";
    }

    Comment


      #3
      question, answer. bravo

      BTW, what is it about?
      Julien
      "Au royaume des aveugles, les borgnes sont mal vus!"
      P. DAC
      Follow me on Twitter @Jbenoit44 - Blog: http://aecuandme.wordpress.com/

      Comment


        #4
        It's about the difference between type and instance parameters. Where for type parameters one needs to get the door type first (door.GetTypeId()) instead of just looping through the instance parameters. I'm not sure if this is the answer, because for this, there are plenty of samples arround
        [email protected]

        http://4revit.com

        Comment

        Related Topics

        Collapse

        Working...
        X