Hi @mohamed_ebrahim3016,
Turns out "BuiltInCategory.OST_Viewers" would also include the Elevation markers.
Below a sample to hide the section lines in active view:
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
IEnumerable<Element> SectionLines = new FilteredElementCollector(doc, doc.ActiveView.Id).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Viewers).ToElements();
List<ElementId> HideElements = new List<ElementId>();
foreach (Element elem in SectionLines)
{
ViewFamilyType VFType = (ViewFamilyType)doc.GetElement(elem.GetTypeId());
if (VFType.FamilyName == "Section")
{
HideElements.Add(elem.Id);
}
}
if (HideElements.Count > 0)
{
using (var t = new Transaction(doc, "Hide Sections in current view"))
{
t.Start();
doc.ActiveView.HideElements(HideElements);
t.Commit();
}
}
return Result.Succeeded;
}
Note that this is a quick sample!, I simply compare the Familyname parameter of the element to get only sectionlines to hide.
Also: this element isn't a view, it's a element, and has several parameters pointing to it's "parent" element, however it does not include the Id of it's "Parent (the Section view itself)", so for now I simply compare to the FamilyName "Section", this would fail in other languages!.
It does have the name, so the Name + Family/Type could be used to determine which element to hide.
Also it does seem as the Section Line element Id is 1 less than it's Parent view. (This is not documented in the api so could change, do not count on it to stay that way.)
- Michel
Ps. If you want to toggle the ends of the sectionline, I haven't found any methods in the ViewSection class that could do that (Like with GridLines there's ShowBubbleInView method)