Boost Your BIM – making Revit even better

March 6, 2013

Extending the Renumber command for Viewports & Detail Number

Filed under: Parameters, Views — harrymattison @ 11:12 am

Here is a response to the comment from Jeff at http://boostyourbim.wordpress.com/2013/01/17/quick-way-to-renumber-doors-grids-and-levels/ on how to extend that tool to work with the Viewport > Detail Number parameter.

2012 2013
private Parameter getParameterForReference(Document doc, Reference r)
{
    Element e = doc.GetElement(r);
    Parameter p = null;
    if (e is Grid)
        p = e.get_Parameter("Name");
    else if (e is Autodesk.Revit.DB.Architecture.Room)
        p = e.get_Parameter("Number");
    else if (e is FamilyInstance)
        p = e.get_Parameter("Mark");
    else
    {
        p = e.get_Parameter("Detail Number");
        if (p == null)
        {
            TaskDialog.Show("Error", "Unsupported element");
            return null;
        }
    }
    return p;
}
private Parameter getParameterForReference(Document doc, Reference r)
{
    Element e = doc.GetElement(r);
    Parameter p = null;
    if (e is Grid)
        p = e.get_Parameter("Name");
    else if (e is Room)
        p = e.get_Parameter("Number");
    else if (e is FamilyInstance)
        p = e.get_Parameter("Mark");
    else if (e is Viewport) // Viewport class is new to Revit 2013 API
        p = e.get_Parameter("Detail Number");
    else
    {
        TaskDialog.Show("Error","Unsupported element");
        return null;
    }
    return p;
}    

The 2012 code can be used in 2013, but I like the 2013 version a bit better for being more explicit about which classes are being checked.

About these ads

2 Comments »

  1. Thanks Harry for showing this!!! No wonder why I have no luck when I was spending an hour yesterday to try to find the Viewport class in Revit 2012 which indeed was not available yet. Good to know that this Viewport class is now available in R2013!

    Comment by Jeff — March 6, 2013 @ 3:51 pm

  2. Thanks Harry re-arranging viewport section/detail number is realy helpfull… it will be nice if re-names the view name in the view browser as well…

    Comment by Babu — March 6, 2013 @ 7:38 pm


RSS feed for comments on this post. TrackBack URI

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 )

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 369 other followers