#RTCEUR Wish 3: Scheduling adaptive point location values

Brian asked how to schedule the location value for placement points in adaptive components.

In a post at https://boostyourbim.wordpress.com/2013/02/14/set-adaptive-component-parameter-values-with-placement-point-coordinates/ I showed how user-defined parameters can be automatically updated with XYZ values of adaptive component points.

If instead what you’d like to do is schedule point parameters such as Measurement Type, Chord Length, and Measure From, the workflow could be something like this:

Capture

 

  1. Create user parameters for each point for each of these parameters
    1. Measurement Type 1
    2. Point Location 1
    3. Measurement Type 2
    4. Point Location 2
    5. etc
  2. Use the API to set these values for every family instance
  3. Use dynamic model update to:
    1. automatically update these user parameters any time the reference point parameters change
    2. automatically update the reference point parameters any time the user parameters change

Capture

This code does step 2 listed above. The approach for Step 3 is covered in the post linked above.
You will note that the Measurement Type is stored internally as an integer and we need to convert from that integer to the corresponding string (Chord Length, Segment Length…) so that we can get the length value from the parameter of the same name.

public void adapt()
{
    Document doc = this.ActiveUIDocument.Document;
    using (Transaction t = new Transaction(doc,"Set Adapt Comp Data"))
    {
        t.Start();
        foreach (FamilyInstance fi in new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).Cast<FamilyInstance>())
        {
            int ctr = 1;
            foreach (ElementId pointId in AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(fi))
            {
                ReferencePoint referencePoint = doc.GetElement(pointId) as ReferencePoint;
                Parameter measurementTypeParam = referencePoint.get_Parameter("Measurement Type");
                if (measurementTypeParam == null)
                    continue;
                
                int i = measurementTypeParam.AsInteger();
                string s = "";
                double paramValue = 0;
                if (i == 1)
                    s = "Non-Normalized Curve Parameter";
                else if (i == 2)
                    s = "Normalized Curve Parameter";
                else if (i == 3)
                    s = "Segment Length";
                else if (i == 4)
                    s = "Normalized Segment Length";
                else if (i == 5)
                    s = "Chord Length";
                
                paramValue = referencePoint.get_Parameter(s).AsDouble();
                
                fi.get_Parameter("Measurement Type " + ctr).Set(s);
                fi.get_Parameter("Point " + ctr).Set(paramValue);
                
                ctr++;
            }
        }
        t.Commit();
    }
}
Advertisements

#RTCEUR Wish 2: Override element display by View Filters

To conclude this set of 3 posts showing how to override display of elements, this shows how to create a view filter for elements with a Comments instance parameter equal to “override”. The list of element ids is used to set this instance parameter. A view filter is created and set to use this rule, the view filter is applied to the view, and the graphics of this filter is overridden.


public void viewFilter()
{
    Document doc = this.ActiveUIDocument.Document;

    OverrideGraphicSettings ogs = new OverrideGraphicSettings();
    ogs.SetCutLineColor(new Color(255,255,0));
    ogs.SetCutLineWeight(6);
    ogs.SetProjectionLineColor(new Color(0,255,255));    
    ogs.SetProjectionLineWeight(6);
    
    IList<ElementId> catIds = new List<ElementId>();
    catIds.Add(doc.Settings.Categories.get_Item("Furniture").Id);
    catIds.Add(doc.Settings.Categories.get_Item("Casework").Id);
    
    IList<FilterRule> rules = new List<FilterRule>();
    ElementId commentParamId = new ElementId(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS);
    rules.Add(ParameterFilterRuleFactory.CreateEqualsRule(commentParamId, "override", true));
    using (Transaction t = new Transaction(doc,"View Filter"))
    {
        t.Start();
                        
        foreach (ElementId id in getIds(doc))
        {
            doc.GetElement(id).get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set("override");
        }
        
        ParameterFilterElement filter = ParameterFilterElement.Create(doc, "New Filter", catIds, rules);
        doc.ActiveView.AddFilter(filter.Id);
        doc.ActiveView.SetFilterOverrides(filter.Id, ogs);
        t.Commit();
    }
}

#RTCEUR API Wish 2: Override display by element ids (isolate)

@DigDesRev asked “so clash detection gives a report w/ element IDs, can we review the report and on 1 view, override the display settings?”

The simplest way to visualize these elements is with Revit’s ‘Temporary Hide/Isolate’ tool

public void isolateElements()
{
    Document doc = this.ActiveUIDocument.Document;    
    using (Transaction t = new Transaction(doc,"Isolate"))
    {
        t.Start();
        doc.ActiveView.IsolateElementsTemporary(getIds(doc));
        t.Commit();
    }
}

getIds() can be whatever function you want to read a clash detection report from disk, find elements in the Revit model, etc.