What i am trying to achieve is my company's standard is to place a graphic scale at the far end of the view title so what have done is created a viewtitle (at various lengths for word wrapping. What i want to do is when i run my routine i will select a viewport and it will read the current viewport type(6" Title ) and replace it will with the type that has graphic scale appended to it(6" Title w/Scale) and then it would fill in the graphic scale values based on what it pulls from the "Scalevalue 1:"
I am still working on applying the values to the viewtitle graphic scale but here is what i have
public void GraphicScale()
{
UIDocument uidoc=this.ActiveUIDocument;
Document doc= uidoc.Document;
ISelectionFilter viewportfilter = new ViewPortPickFilter();
Reference refa = uidoc.Selection.PickObject(ObjectType.Element, viewportfilter, "Select a viewport.");
Element e = doc.GetElement(refa);
//get view associated with viewport,
FilteredElementCollector viewCollector = new FilteredElementCollector(doc).OfClass(typeof(View)).
using (Transaction trans = new Transaction(doc, "Rename Sheets"))
{
trans.Start();
{
Parameter paramscalefactor = e.LookupParameter("Scale Value 1:");
double vscalefactor = Convert.ToDouble(paramscalefactor.AsValueString());
e.LookupParameter("SCALE1").Set(vscalefactor/24);
e.LookupParameter("SCALE2").Set(vscalefactor/12);
e.LookupParameter("SCALE3").Set(vscalefactor/8);
e.LookupParameter("SCALE4").Set(vscalefactor/6);
//TaskDialog.Show("Test","Graphic Scale is "+vscalefactor);
}
trans.Commit();
}
}
}
public class ViewPortPickFilter : ISelectionFilter
{
public bool AllowElement(Element e)
{
return (e.Category.Id.IntegerValue.Equals(
(int)BuiltInCategory.OST_Viewports));
}
public bool AllowReference(Reference r, XYZ p)
{
return false;
}
}
}