class DuctTypeModel { [NodeName("DuctTypes")] [NodeCategory("DynaMEP.DynaMEP.MEP.Ducts")] [NodeDescription("Get All Duct Type From Model Dropdown")] [IsDesignScriptCompatible] [IsVisibleInDynamoLibrary(true)] public class DuctTypeUi : DSDropDownBase { const string NoDuctTypes = "No types were found."; /// /// public DuctTypeUi() : base("DuctType") { } /// /// /// /// protected override SelectionState PopulateItemsCore(string currentSelection) { Items.Clear(); Document doc = DocumentManager.Instance.CurrentDBDocument; List vtList = new FilteredElementCollector(doc).OfClass(typeof(DuctType)).ToList(); if (vtList.Count == 0) { Items.Add(new DynamoDropDownItem(NoDuctTypes, null)); SelectedIndex = 0; return SelectionState.Done; } foreach (var element in vtList) { var v = (DuctType) element; Items.Add(new DynamoDropDownItem(v.Name, v)); } Items = Items.OrderBy(x => x.Name).ToObservableCollection(); return SelectionState.Restore; } /// /// /// /// public override IEnumerable BuildOutputAst(List inputAstNodes) { AssociativeNode node; if (SelectedIndex == -1) { node = AstFactory.BuildNullNode(); } else { DuctType ductType = Items[SelectedIndex].Item as DuctType; StringNode idNode = AstFactory.BuildStringNode(ductType.Name); BooleanNode falseNode = AstFactory.BuildBooleanNode(true); node = AstFactory.BuildFunctionCall( new Func(ElementSelector.ByUniqueId), new List {idNode, falseNode}); } return new[] {AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node)}; } } }