/* The BuiltInParameter bip could be one or more of following params : * BuiltInParameter.VIEW_SCALE_PULLDOWN_METRIC, * BuiltInParameter.VIEW_DETAIL_LEVEL, * BuiltInParameter.VIEW_PARTS_VISIBILITY, * BuiltInParameter.VIS_GRAPHICS_MODEL, * BuiltInParameter.VIS_GRAPHICS_ANNOTATION, * BuiltInParameter.VIS_GRAPHICS_ANALYTICAL_MODEL, * BuiltInParameter.VIS_GRAPHICS_IMPORT, * BuiltInParameter.VIS_GRAPHICS_FILTERS, * BuiltInParameter.VIS_GRAPHICS_RVT_LINKS, * BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_MODEL, * BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_SHADOWS, * BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_SKETCHY_LINES, * BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_LIGHTING, * BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_PHOTO_EXPOSURE, * BuiltInParameter.GRAPHIC_DISPLAY_OPTIONS_BACKGROUND, * BuiltInParameter.VIEW_PHASE_FILTER, * BuiltInParameter.VIEW_DISCIPLINE, * BuiltInParameter.VIEW_SHOW_HIDDEN_LINES, * BuiltInParameter.VIEWER3D_RENDER_SETTINGS */ public static void IncludParamToViewTemplate( Document doc, Autodesk.Revit.DB.View viewTemplate, List <BuiltInParameter> bipList) { Transaction t = new Transaction(doc); foreach (BuiltInParameter bip in bipList) { if (viewTemplate.GetNonControlledTemplateParameterIds().Count != 0) { ElementId VMDMode_Id = ElementId.InvalidElementId; List <ElementId> nonControlledParams = viewTemplate.GetNonControlledTemplateParameterIds().ToList(); foreach (var id in nonControlledParams) { if (id.IntegerValue == (int)bip) { VMDMode_Id = id; break; } } if (VMDMode_Id != ElementId.InvalidElementId) // The param is not include in view template { nonControlledParams.Remove(new ElementId(bip)); t.Start("Set non controlled params to template"); viewTemplate.SetNonControlledTemplateParameterIds(nonControlledParams); t.Commit(); } } } }
public override Form DrillDown() { if (!HasDrillDown) { return(null); } var nonControlledTemplateParameterIds = _view.GetNonControlledTemplateParameterIds() .Select(id => _view.Parameters .Cast <Parameter>() .ToList() .Find(q => q.Id.IntegerValue == id.IntegerValue)) .Where(p => p is not null) .Select(p => new SnoopableWrapper(p.Definition.Name, p)).ToList(); if (nonControlledTemplateParameterIds.Count == 0) { return(null); } var form = new ObjectsView(nonControlledTemplateParameterIds); return(form); }
/// <summary> /// Gets the ElementIds of the view's parameters that are NOT controlled by a view template. /// </summary> /// <param name="View">A dynamo wrapped View</param> /// <returns name="ElementIds">A list of ElementIds that are NOT controlled by a view template.</returns> public static IList <revitElemId> GetNonControlledTemplateParameterIds(dynaView View) { revitView rView = (revitView)View.InternalElement; return((IList <revitElemId>)rView.GetNonControlledTemplateParameterIds()); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { _uiapp = commandData.Application; _uidoc = _uiapp.ActiveUIDocument; _doc = _uidoc.Document; Autodesk.Revit.DB.View actView = _doc.ActiveView; List <Element> elemList = new List <Element>(); Autodesk.Revit.DB.View template = null; if (actView.ViewTemplateId != ElementId.InvalidElementId) { template = _doc.GetElement(actView.ViewTemplateId) as Autodesk.Revit.DB.View; } bool VGCtrlByTmp = false; if (template != null) // The view is controlled by a view template { List <ElementId> nonControledParamsIds = template.GetNonControlledTemplateParameterIds().ToList(); // graphics visibility param is included in the view template VGCtrlByTmp = !nonControledParamsIds.Any( id => id.IntegerValue == (int)BuiltInParameter.VIS_GRAPHICS_MODEL ); } IList <Reference> select = new List <Reference>(); try { select = _uidoc.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element); } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { return(Result.Cancelled); } using (Transaction t = new Transaction(_doc, "Hide categories")) { t.Start(); foreach (Reference elemRef in select) { Element elem = _doc.GetElement(elemRef); if (VGCtrlByTmp) { if (template.CanCategoryBeHidden(elem.Category.Id)) { template.SetCategoryHidden(elem.Category.Id, true); } else { MessageBox.Show( $"The category \"{elem.Category.Name}\" of \"{elem.Name}\" can not be hidden!", "Categories can't be hidden" ); } } else { actView.SetCategoryHidden(_doc.GetElement(elemRef).Category.Id, true); } } t.Commit(); } return(Result.Succeeded); }