#RTCNA2016 Wish 2 Granted (part 2)

The previous post showed how to create lines in an elevation view to visualize the view range of a plan view. Now let’s see how to let the user move those lines in the elevation view and update the plan view’s range.

public void setViewRangeByLine()
{
    string planName = "Level 1 View Range Test";

    Document doc = this.ActiveUIDocument.Document;
    
    ViewPlan viewPlan = new FilteredElementCollector(doc)
        .OfClass(typeof(ViewPlan))
        .Cast<ViewPlan>()
        .FirstOrDefault(q => q.Name == planName);
    if (viewPlan == null)
        return;
    
    CurveElement bottomCurve = new FilteredElementCollector(doc, doc.ActiveView.Id)
        .OfClass(typeof(CurveElement))
        .Cast<CurveElement>().FirstOrDefault(q => q.LineStyle.Name == "Bottom Clip Plane");
    if (bottomCurve == null)
        return;
    
    double bottomZ = bottomCurve.GeometryCurve.GetEndPoint(0).Z;

    PlanViewRange range = viewPlan.GetViewRange();
    using (Transaction t = new Transaction(doc, "Set view range"))
    {
        t.Start();
        range.SetOffset(PlanViewPlane.BottomClipPlane, bottomZ);
        viewPlan.SetViewRange(range);
        t.Commit();
    }
    
}

One thought on “#RTCNA2016 Wish 2 Granted (part 2)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s