/// <summary> /// Adds a local DynNode to search /// </summary> /// <param name="dynNode">A Dynamo node object</param> public void Add(dynNode dynNode) { var searchEle = new LocalSearchElement(dynNode); // add category to search var cat = dynNode.Category; if (!string.IsNullOrEmpty(cat)) { if (!cat.StartsWith("Revit API")) { SearchDictionary.Add(searchEle, cat + "." + searchEle.Name); if (!NodeCategories.ContainsKey(cat)) { var nameEle = new CategorySearchElement(cat); NodeCategories.Add(cat, nameEle); SearchDictionary.Add(nameEle, cat); } } else { if (!NodeCategories.ContainsKey(cat)) { var nameEle = new CategorySearchElement(cat); NodeCategories.Add(cat, nameEle); RevitApiSearchElements.Add(nameEle); } } } NodeCategories[cat].NumElements++; // add node to search if ( (searchEle.Name.StartsWith("API_")) ) { RevitApiSearchElements.Add( searchEle ); } else { SearchDictionary.Add(searchEle, searchEle.Name); if (dynNode.NodeUI.Tags.Count > 0) { SearchDictionary.Add(searchEle, dynNode.NodeUI.Tags); } SearchDictionary.Add(searchEle, dynNode.NodeUI.Description); } }
/// <summary> /// Add a custom node to search. /// </summary> /// <param name="workspace">A dynWorkspace to add</param> /// <param name="name">The name to use</param> public void Add(string name, string category, Guid functionId) { if (name == "Home") return; // create the workspace in search var workspaceEle = new WorkspaceSearchElement(name, "Navigate to workspace called " + name); workspaceEle.Guid = functionId; if (!NodeCategories.ContainsKey(category)) { NodeCategories.Add(category, new CategorySearchElement(category)); } NodeCategories[category].NumElements++; SearchDictionary.Add(workspaceEle, workspaceEle.Name); // create the node in search var nodeEle = new LocalSearchElement(name, functionId); SearchDictionary.Add(nodeEle, nodeEle.Name); SearchDictionary.Add(nodeEle, category + "." + nodeEle.Name); }
/// <summary> /// Adds a local DynNode to search /// </summary> /// <param name="dynNode">A Dynamo node object</param> public void Add(Type t) { // get name, category, attributes object[] attribs = t.GetCustomAttributes(typeof(NodeNameAttribute), false); var name = ""; if (attribs.Length > 0) { name = (attribs[0] as NodeNameAttribute).Name; } attribs = t.GetCustomAttributes(typeof(NodeCategoryAttribute), false); var cat = ""; if (attribs.Length > 0) { cat = (attribs[0] as NodeCategoryAttribute).ElementCategory; } attribs = t.GetCustomAttributes(typeof(NodeSearchTagsAttribute), false); var tags = new List<string>(); if (attribs.Length > 0) { tags = (attribs[0] as NodeSearchTagsAttribute).Tags; } attribs = t.GetCustomAttributes(typeof(NodeDescriptionAttribute), false); var description = ""; if (attribs.Length > 0) { description = (attribs[0] as NodeDescriptionAttribute).ElementDescription; } var searchEle = new LocalSearchElement(name, description, tags); if (!string.IsNullOrEmpty(cat)) { if (!cat.StartsWith("Revit API")) { SearchDictionary.Add(searchEle, cat + "." + searchEle.Name); if (!NodeCategories.ContainsKey(cat)) { var nameEle = new CategorySearchElement(cat); NodeCategories.Add(cat, nameEle); SearchDictionary.Add(nameEle, cat); } } else { if (!NodeCategories.ContainsKey(cat)) { var nameEle = new CategorySearchElement(cat); NodeCategories.Add(cat, nameEle); RevitApiSearchElements.Add(nameEle); } } } NodeCategories[cat].NumElements++; // add node to search if ((searchEle.Name.StartsWith("API_"))) { RevitApiSearchElements.Add(searchEle); } else { SearchDictionary.Add(searchEle, searchEle.Name); if (tags.Count > 0) { SearchDictionary.Add(searchEle, tags); } SearchDictionary.Add(searchEle, description); } }
/// <summary> /// Adds a Workspace object with a given Name /// </summary> /// <param name="workspace">A dynWorkspace to add</param> /// <param name="name">The name to use</param> public void Add(dynWorkspace workspace, string name) { if (name == "Home") return; // create the workspace in search var searchEle = new WorkspaceSearchElement(name, "Go to " + name ); var funcDef = dynSettings.Controller.CustomNodeLoader.GetDefinitionFromWorkspace(workspace); searchEle.Guid = funcDef.FunctionId; if (searchEle.Guid == Guid.Empty) return; SearchDictionary.Add(searchEle, searchEle.Name); // create the node in search var nodeEle = new LocalSearchElement(funcDef); SearchDictionary.Add(nodeEle, name); // update search SearchAndUpdateResultsSync(SearchText); }