private Parameter getParameterForReference(Document doc, Reference r)
{
Element e = doc.GetElement(r);
Parameter p = null;
if (e is Grid)
p = e.get_Parameter("Name");
elseif (e is Autodesk.Revit.DB.Architecture.Room)
p = e.get_Parameter("Number");
elseif (e is FamilyInstance)
p = e.get_Parameter("Mark");
else
{
p = e.get_Parameter("Detail Number");
if (p == null)
{
TaskDialog.Show("Error", "Unsupported element");
returnnull;
}
}
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");
elseif (e is Room)
p = e.get_Parameter("Number");
elseif (e is FamilyInstance)
p = e.get_Parameter("Mark");
elseif (e is Viewport) // Viewport class is new to Revit 2013 API
p = e.get_Parameter("Detail Number");
else
{
TaskDialog.Show("Error","Unsupported element");
returnnull;
}
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.
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!
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
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