/// <summary> /// Add a new parameter, "Unique ID", to the beams and slabs /// The following process should be followed: /// Open the shared parameters file, via the Document.OpenSharedParameterFile method. /// Access an existing group or create a new group, via the DefinitionFile.Groups property. /// Access an existing or create a new external parameter definition, /// via the DefinitionGroup.Definitions property. /// Create a new Binding with the categories to which the parameter will be bound /// using an InstanceBinding or a TypeBinding. /// Finally add the binding and definition to the document /// using the Document.ParameterBindings object. /// </summary> /// <returns>bool type, a value that signifies if add parameter was successful</returns> public bool SetNewParameterToBeamsAndSlabs() { //Open the shared parameters file // via the private method AccessOrCreateExternalSharedParameterFile DefinitionFile informationFile = AccessOrCreateExternalSharedParameterFile(); if (null == informationFile) { return(false); } // Access an existing or create a new group in the shared parameters file DefinitionGroups informationCollections = informationFile.Groups; DefinitionGroup informationCollection = null; informationCollection = informationCollections.get_Item("MyParameters"); if (null == informationCollection) { informationCollections.Create("MyParameters"); informationCollection = informationCollections.get_Item("MyParameters"); } // Access an existing or create a new external parameter definition // belongs to a specific group Definition information = informationCollection.Definitions.get_Item("Unique ID"); if (null == information) { ExternalDefinitionCreationOptions ExternalDefinitionCreationOptions = new ExternalDefinitionCreationOptions("Unique ID", Autodesk.Revit.DB.SpecTypeId.String.Text); informationCollection.Definitions.Create(ExternalDefinitionCreationOptions); information = informationCollection.Definitions.get_Item("Unique ID"); } // Create a new Binding object with the categories to which the parameter will be bound CategorySet categories = m_revit.Application.Create.NewCategorySet(); Category structuralFramingCategorie = null; Category floorsClassification = null; // use category in instead of the string name to get category structuralFramingCategorie = m_revit.ActiveUIDocument.Document.Settings.Categories.get_Item(BuiltInCategory.OST_StructuralFraming); floorsClassification = m_revit.ActiveUIDocument.Document.Settings.Categories.get_Item(BuiltInCategory.OST_Floors); categories.Insert(structuralFramingCategorie); categories.Insert(floorsClassification); InstanceBinding caseTying = m_revit.Application.Create.NewInstanceBinding(categories); // Add the binding and definition to the document bool boundResult = m_revit.ActiveUIDocument.Document.ParameterBindings.Insert(information, caseTying); return(boundResult); }
public static Definition GetDefinition(string name, Model.DefinitionGroupType defGroupType, ParameterType paramType) { Definition def = null; DefinitionFile defFile = revitData.Application.OpenSharedParameterFile(); if (defFile == null) { CreateSharedParameterFile(Constant.ConstantValue.SharedParameterFileName); defFile = revitData.Application.OpenSharedParameterFile(); } DefinitionGroups defGroups = defFile.Groups; var defGroup = defGroups.get_Item(defGroupType.ToString()); if (defGroup == null) { defGroup = defGroups.Create(defGroupType.ToString()); } var defs = defGroup.Definitions; def = defs.get_Item(name); if (def == null) { def = defGroup.Definitions.Create(new ExternalDefinitionCreationOptions(name, paramType) { UserModifiable = true }); } return(def); }
private DefinitionGroup GetSharedGroup() { string sharedParametersFile = this.GetSharedParametersFile(); this.m_revitApp.SharedParametersFilename = sharedParametersFile; DefinitionFile definitionFile = this.m_revitApp.OpenSharedParameterFile(); if (definitionFile == null) { return(null); } DefinitionGroups groups = definitionFile.Groups; DefinitionGroup definitionGroup = groups.get_Item("RDBParameters"); if (definitionGroup == null) { groups.Create("RDBParameters"); definitionGroup = groups.get_Item("RDBParameters"); } return(definitionGroup); }
private void bttnCreate_Click(object sender, EventArgs e) { Definition definition = null; using (Transaction trans = new Transaction(m_doc)) { trans.Start("Create Shared Parameter"); try { defDictionary.Clear(); DefinitionGroups dGroups = definitionFile.Groups; DefinitionGroup dGroup = dGroups.get_Item("HOK Mass Parameters"); if (null == dGroup) { dGroup = dGroups.Create("HOK Mass Parameters"); } Definitions definitions = dGroup.Definitions; foreach (ListViewItem item in listViewMassParameter.Items) { definition = definitions.get_Item("Mass_" + item.Text); Parameter parameter = item.Tag as Parameter; if (null == definition && null != parameter) { ParameterType paramType = parameter.Definition.ParameterType; #if RELEASE2013 || RELEASE2014 definition = definitions.Create("Mass_" + parameter.Definition.Name, paramType); #elif RELEASE2015 ExternalDefinitonCreationOptions options = new ExternalDefinitonCreationOptions("Mass_" + parameter.Definition.Name, paramType); definition = definitions.Create(options); #elif RELEASE2016 ExternalDefinitionCreationOptions options = new ExternalDefinitionCreationOptions("Mass_" + parameter.Definition.Name, paramType); definition = definitions.Create(options); #endif } if (!defDictionary.ContainsKey(parameter.Definition.Name)) { defDictionary.Add(parameter.Definition.Name, definition); } } trans.Commit(); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Failed to set shared parameters.\n" + ex.Message, "Form_Parameters:CreateButtonClick", MessageBoxButtons.OK, MessageBoxIcon.Warning); trans.RollBack(); } } }
private ExternalDefinition GetSharedParameter(DefinitionFile file, string group, string name) { DefinitionGroups myGroups = file.Groups; DefinitionGroup myGroup = myGroups.get_Item(group); ExternalDefinition extDef = null; if (myGroup != null) { extDef = myGroup.Definitions.get_Item(name) as ExternalDefinition; } return(extDef); }
/// <summary> /// Gets definition groups by sharing parameter file path. /// </summary> /// <param name="groups"></param> /// <param name="groupName"></param> /// <returns></returns> public static DefinitionGroup GetGroup(this DefinitionGroups groups, string groupName) { if (groups == null) { throw new ArgumentNullException(nameof(groups)); } if (groupName == null) { throw new ArgumentNullException(nameof(groupName)); } return(groups.get_Item(groupName) ?? groups.Create(groupName)); }
public bool AddShadeParameter(Document doc, string groupName, string parameterName, Category category, bool isInstance) { if (this.path == "") { throw new Exception("路径无效"); } doc.Application.SharedParametersFilename = this.path; DefinitionFile definitionFile = doc.Application.OpenSharedParameterFile(); DefinitionGroups groups = definitionFile.Groups; DefinitionGroup group = groups.get_Item(groupName); if (group == null) { throw new Exception("没有找到对应的参数组,组名:" + groupName); } Definition definition = group.Definitions.get_Item(parameterName); if (definition == null) { throw new Exception("没有找到对应的参数,参数名:" + parameterName); } ElementBinding binding = null; ElementBinding bind = doc.ParameterBindings.get_Item(definition) as ElementBinding; CategorySet set = new CategorySet();; if (bind != null) { foreach (Category c in bind.Categories) { set.Insert(c); } } var b = set.Insert(category); if (isInstance) { binding = doc.Application.Create.NewInstanceBinding(set); } else { binding = doc.Application.Create.NewTypeBinding(set); } doc.ParameterBindings.Remove(definition); return(doc.ParameterBindings.Insert(definition, binding, BuiltInParameterGroup.PG_TEXT)); }
public void AddExistingSharedParameter(string groupOfSharedParam, string name, CategorySet cats, BuiltInParameterGroup group, bool inst) { try { AplicationRvt.SharedParametersFilename = GetNewSharedParameterFilePath(); DefinitionFile defFile = AplicationRvt.OpenSharedParameterFile(); if (defFile == null) { throw new Exception("No SharedParameter File!"); } DefinitionGroups myGroups = defFile.Groups; DefinitionGroup myGroup = myGroups.get_Item(groupOfSharedParam); ExternalDefinition def = null; if (myGroup == null) { throw new Exception("The group doesn't exist. Inspect name of group"); } def = myGroup.Definitions.get_Item(name) as ExternalDefinition; if (def == null) { throw new Exception("The parameter doesnt exist"); } Binding binding = AplicationRvt.Create.NewTypeBinding(cats); if (inst) { binding = AplicationRvt.Create.NewInstanceBinding(cats); } BindingMap map = (new UIApplication(AplicationRvt)).ActiveUIDocument.Document.ParameterBindings; map.Insert(def, binding, group); SetExistingSharedParameterFile(); } finally { SetExistingSharedParameterFile(); } }
public static bool AddSharedParameterByDefaulGroupName(Document doc, string sharedParameterFile, string groupName, string parameterName, Category newCategory, bool isInstance, BuiltInParameterGroup parameterGroup) { doc.Application.SharedParametersFilename = sharedParameterFile; DefinitionFile definitionFile = doc.Application.OpenSharedParameterFile(); DefinitionGroups groups = definitionFile.Groups; DefinitionGroup group = groups.get_Item(groupName); if (group == null) { throw new Exception("没有找到对应的参数组"); } Definition definition = group.Definitions.get_Item(parameterName); if (definition == null) { throw new Exception("没有找到对应的参数"); } ElementBinding binding = null; ElementBinding orientBinding = doc.ParameterBindings.get_Item(definition) as ElementBinding; CategorySet categories = new CategorySet();; if (orientBinding != null) { foreach (Category c in orientBinding.Categories) { categories.Insert(c); } } categories.Insert(newCategory); if (isInstance) { binding = doc.Application.Create.NewInstanceBinding(categories); } else { binding = doc.Application.Create.NewTypeBinding(categories); } doc.ParameterBindings.Remove(definition); var result = doc.ParameterBindings.Insert(definition, binding, parameterGroup); return(result); }
public static void PrepareSharedParameter(Document doc) { doc.Application.SharedParametersFilename = SharedParameterFile; if (!File.Exists(SharedParameterFile)) { var fs = File.Create(SharedParameterFile); fs.Close(); } DefinitionFile definitionFile = doc.Application.OpenSharedParameterFile(); DefinitionGroups groups = definitionFile.Groups; DefinitionGroup group = groups.get_Item(GroupName); if (group == null) { group = definitionFile.Groups.Create(GroupName); group.Definitions.Create(new ExternalDefinitionCreationOptions(CustomParameters.监测类型.ToString(), ParameterType.Text)); group.Definitions.Create(new ExternalDefinitionCreationOptions(CustomParameters.测点编号.ToString(), ParameterType.Text)); group.Definitions.Create(new ExternalDefinitionCreationOptions(CustomParameters.监测点.ToString(), ParameterType.Text)); } }
/// <summary> /// Gets definition groups by sharing parameter file path. /// </summary> /// <param name="groups"></param> /// <param name="groupName"></param> /// <returns></returns> public static DefinitionGroup GetGroup(this DefinitionGroups groups, string groupName) { return(groups.get_Item(groupName) ?? groups.Create(groupName)); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { //String Builder StringBuilder sb = new StringBuilder(); // Application context. UIApplication uiapp = commandData.Application; Application app = uiapp.Application; var uidoc = commandData.Application.ActiveUIDocument; var doc = uidoc.Document; //Shared parameter file string oldlFile = app.SharedParametersFilename; string newFile = @"C:\RenameSharedParameters\FAC_shared_parameters.txt"; app.SharedParametersFilename = newFile; DefinitionFile sharedParameterFile = app.OpenSharedParameterFile(); //Shared parameter group settings DefinitionGroups defGroups = sharedParameterFile.Groups; sb.Append(defGroups.Size + "\n"); DefinitionGroup defGroup = defGroups.get_Item("Facedo"); FamilyManager fman = doc.FamilyManager; using (Transaction tx = new Transaction(doc, "to family parameter")) { tx.Start(); foreach (FamilyParameter p in fman.Parameters) { if (p.Definition.Name.Contains("MDK")) { try { fman.ReplaceParameter(p, p.Definition.Name.Replace("MDK", "TEMP"), p.Definition.ParameterGroup, p.IsInstance); sb.Append(p.Definition.Name + "\n"); } catch { } } } tx.Commit(); } sb.Append("\n"); using (Transaction tx = new Transaction(doc, "to shared parameter")) { tx.Start(); foreach (FamilyParameter p in fman.Parameters) { if (p.Definition.Name.Contains("TEMP")) { try { string newname = p.Definition.Name.Replace("TEMP", "FAC"); ExternalDefinitionCreationOptions opt = new ExternalDefinitionCreationOptions(newname, p.Definition.ParameterType); defGroup.Definitions.Create(opt); ExternalDefinition newExtDef = defGroup.Definitions.get_Item(newname) as ExternalDefinition; fman.ReplaceParameter(p, newname, p.Definition.ParameterGroup, p.IsInstance); sb.Append(p.Definition.Name + "\n"); } catch { } } } tx.Commit(); } TaskDialog.Show("Final Dialog", sb.ToString()); return(Result.Succeeded); }
/// <summary> /// Add shared parameters needed in this sample. /// parameter 1: one string parameter named as "BasalOpening" which is used for customization of door opening for each country. /// parameter 2: one string parameter named as "InstanceOpening" to indicate the door's opening value. /// parameter 3: one YESNO parameter named as "Internal Door" to flag the door is internal door or not. /// </summary> /// <param name="app">Revit application.</param> public static void AddSharedParameters(UIApplication app) { // Create a new Binding object with the categories to which the parameter will be bound. CategorySet categories = app.Application.Create.NewCategorySet(); // get door category and insert into the CategorySet. Category doorCategory = app.ActiveUIDocument.Document.Settings.Categories. get_Item(BuiltInCategory.OST_Doors); categories.Insert(doorCategory); // create one instance binding for "Internal Door" and "InstanceOpening" parameters; // and one type binding for "BasalOpening" parameters InstanceBinding instanceBinding = app.Application.Create.NewInstanceBinding(categories); TypeBinding typeBinding = app.Application.Create.NewTypeBinding(categories); BindingMap bindingMap = app.ActiveUIDocument.Document.ParameterBindings; // Open the shared parameters file // via the private method AccessOrCreateSharedParameterFile DefinitionFile defFile = AccessOrCreateSharedParameterFile(app.Application); if (null == defFile) { return; } // Access an existing or create a new group in the shared parameters file DefinitionGroups defGroups = defFile.Groups; DefinitionGroup defGroup = defGroups.get_Item("DoorProjectSharedParameters"); if (null == defGroup) { defGroup = defGroups.Create("DoorProjectSharedParameters"); } // Access an existing or create a new external parameter definition belongs to a specific group. // for "BasalOpening" if (!AlreadyAddedSharedParameter(app.ActiveUIDocument.Document, "BasalOpening", BuiltInCategory.OST_Doors)) { Definition basalOpening = defGroup.Definitions.get_Item("BasalOpening"); if (null == basalOpening) { basalOpening = defGroup.Definitions.Create("BasalOpening", ParameterType.Text, false); } // Add the binding and definition to the document. bindingMap.Insert(basalOpening, typeBinding, BuiltInParameterGroup.PG_GEOMETRY); } // for "InstanceOpening" if (!AlreadyAddedSharedParameter(app.ActiveUIDocument.Document, "InstanceOpening", BuiltInCategory.OST_Doors)) { Definition instanceOpening = defGroup.Definitions.get_Item("InstanceOpening"); if (null == instanceOpening) { instanceOpening = defGroup.Definitions.Create("InstanceOpening", ParameterType.Text, true); } // Add the binding and definition to the document. bindingMap.Insert(instanceOpening, instanceBinding, BuiltInParameterGroup.PG_GEOMETRY); } // for "Internal Door" if (!AlreadyAddedSharedParameter(app.ActiveUIDocument.Document, "Internal Door", BuiltInCategory.OST_Doors)) { Definition internalDoorFlag = defGroup.Definitions.get_Item("Internal Door"); if (null == internalDoorFlag) { internalDoorFlag = defGroup.Definitions.Create("Internal Door", ParameterType.YesNo, true); } // Add the binding and definition to the document. bindingMap.Insert(internalDoorFlag, instanceBinding); } }
private static string CreateProjectParameters(Application app, Document doc, List <Category> RevitCategories, List <string> Parameters, string GroupName) { int newParameters = 0; int newCategories = 0; CategorySet tempCategorySet = app.Create.NewCategorySet(); foreach (Category item in RevitCategories) { IList <Element> fec = new FilteredElementCollector(doc).OfCategoryId(item.Id).WhereElementIsNotElementType().ToElements(); if (fec.Count > 0) { tempCategorySet.Insert(item); } } //get the parameter file string sharedParameterFile = doc.Application.SharedParametersFilename; DefinitionGroups existingGroups = app.OpenSharedParameterFile().Groups; DefinitionGroup groupName = existingGroups.get_Item(GroupName); if (existingGroups.get_Item(GroupName) == null) { groupName = existingGroups.Create(GroupName); //store under Data } try { foreach (string name in Parameters) { if (!tempCategorySet.IsEmpty) { //shared parameter does not exist if (groupName.Definitions.get_Item(name) == null) { InstanceBinding newInstanceBinding = app.Create.NewInstanceBinding(tempCategorySet); //cats ExternalDefinition externalDefinition = groupName.Definitions.Create(new ExternalDefinitionCreationOptions(name, ParameterType.Text)) as ExternalDefinition; doc.ParameterBindings.Insert(externalDefinition, newInstanceBinding, BuiltInParameterGroup.PG_DATA); newParameters++; } //shared parameter exists else { ExternalDefinition existingDefinition = groupName.Definitions.get_Item(name) as ExternalDefinition; ElementBinding binding = doc.ParameterBindings.get_Item(existingDefinition) as ElementBinding; //additional categories added to an existing shared parameter (re-insert) if (binding != null) { foreach (Category item in binding.Categories) { tempCategorySet.Insert(item); } InstanceBinding newInstanceBinding = app.Create.NewInstanceBinding(tempCategorySet); //cats doc.ParameterBindings.ReInsert(existingDefinition, newInstanceBinding, BuiltInParameterGroup.PG_DATA); newCategories++; } //shared parameter exists but has never been inserted (if the user undo the operation) else { InstanceBinding newInstanceBinding = app.Create.NewInstanceBinding(tempCategorySet); //cats doc.ParameterBindings.Insert(existingDefinition, newInstanceBinding, BuiltInParameterGroup.PG_DATA); newCategories++; } } } } } catch (Exception ex) { TaskDialog.Show("Error", ex.Message); } finally { app.SharedParametersFilename = sharedParameterFile; } //File.Delete(tempSharedParameterFile); return($"Parameters created: {newParameters}\nParameters categories updated: {newCategories}"); }
private void StoreSharedParams() { using (Transaction trans = new Transaction(doc)) { trans.Start("Store Shared Parameters"); try { string currentAssembly = System.Reflection.Assembly.GetAssembly(this.GetType()).Location; string definitionPath = Path.GetDirectoryName(currentAssembly) + "/Resources/Mass Shared Parameters.txt"; m_app.SharedParametersFilename = definitionPath; definitionFile = m_app.OpenSharedParameterFile(); FilteredElementCollector collector = new FilteredElementCollector(doc); Element element = null; List <string> activeSharedParams = new List <string>(); switch (massCategory) { case MassCategory.Rooms: element = collector.OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements().First(); activeSharedParams = roomSharedParameters; break; case MassCategory.Areas: element = collector.OfCategory(BuiltInCategory.OST_Areas).WhereElementIsNotElementType().ToElements().First(); activeSharedParams = areaSharedParameters; break; case MassCategory.Floors: element = collector.OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements().First(); activeSharedParams = floorSharedParameters; break; } if (null != definitionFile) { DefinitionGroups dGroups = definitionFile.Groups; DefinitionGroup dGroup = dGroups.get_Item("HOK Mass Parameters"); if (null == dGroup) { dGroup = dGroups.Create("HOK Mass Parameters"); } Definitions definitions = dGroup.Definitions; Definition definition; foreach (string paramName in activeSharedParams) { definition = definitions.get_Item("Mass_" + paramName); if (null == definition) { #if RELEASE2013 || RELEASE2014 Parameter param = element.get_Parameter(paramName); definition = definitions.Create("Mass_" + param.Definition.Name, param.Definition.ParameterType); #elif RELEASE2015 Parameter param = element.LookupParameter(paramName); ExternalDefinitonCreationOptions options = new ExternalDefinitonCreationOptions("Mass_" + param.Definition.Name, param.Definition.ParameterType); definition = definitions.Create(options); #elif RELEASE2016 Parameter param = element.LookupParameter(paramName); ExternalDefinitionCreationOptions options = new ExternalDefinitionCreationOptions("Mass_" + param.Definition.Name, param.Definition.ParameterType); definition = definitions.Create(options); #endif } if (null != definition && !defDictionary.ContainsKey(paramName)) { defDictionary.Add(paramName, definition); } } } trans.Commit(); } catch (Exception ex) { MessageBox.Show("Failed to store shared parameters.\n" + ex.Message, "Form_RoomMass:StoreSharedParams", MessageBoxButtons.OK, MessageBoxIcon.Warning); trans.RollBack(); } } }
/// <summary> /// Creates new shared parameter if it does not exist and bind it to the type or instance of the objects /// </summary> /// <param name="paramType">Type of the parameter</param> /// <param name="categoriesForParam">Category of elements to bind the parameter to</param> /// <param name="defaultGroupName">Group name of the parameters</param> /// <param name="parameterName">Name of the parameter</param> /// <returns>TRUE if shared parameter is created, FALSE otherwise</returns> public static bool SetNewSharedParameter(this Element element, ParameterType paramType, CategorySet categoriesForParam, string parameterName, BuiltInParameterGroup group) { string defaultGroupName = "4P_imported_parameters"; //this is a hack to avoid multiple parameters with the same name. if (categoriesForParam == null) { return(false); } if (categoriesForParam.Size == 0) { return(false); } foreach (Category cat in categoriesForParam) { if (cat == null) { return(false); } if (!cat.AllowsBoundParameters) { return(false); } } Application application = element.Document.Application; Document document = element.Document; if (_definitionFile == null) { //ask for the location of the shared parameters file var dialog = new Microsoft.Win32.OpenFileDialog(); dialog.CheckFileExists = false; dialog.Title = "Set shared pID file..."; dialog.ShowDialog(); string shrFilePath = dialog.FileName; if (shrFilePath == null) { _definitionFile = application.OpenSharedParameterFile(); if (_definitionFile == null) { SetSharedParamFileInUserProgramFolder(document); } } else { SetDefinitionFile(element, shrFilePath); } } if (_definitionFile == null) { throw new Exception("Definition file must be set before creation of the new parameters."); } DefinitionFile myDefinitionFile = _definitionFile; // Get parameter or create new one DefinitionGroups myGroups = myDefinitionFile.Groups; Definition myDefinition = null; bool found = false; foreach (DefinitionGroup gr in myGroups) { foreach (Definition def in gr.Definitions) { if (def.Name == parameterName) { myDefinition = def; found = true; break; } } if (found) { break; } } //if there is not such a parameter new one is created in default group if (myDefinition == null) { DefinitionGroup myGroup = myGroups.get_Item(defaultGroupName); if (myGroup == null) { myGroup = myGroups.Create(defaultGroupName); } // Create a type definition myDefinition = myGroup.Definitions.get_Item(parameterName); if (myDefinition == null) { myDefinition = myGroup.Definitions.Create(parameterName, paramType); } } //Create an object of TypeBinding or InstanceBinding according to the Categories and "typeBinding" variable Binding binding = null; // Get the BingdingMap of current document. BindingMap bindingMap = document.ParameterBindings; binding = bindingMap.get_Item(myDefinition); bool bindOK = false; if (!element.CanHaveTypeAssigned() && !(element is Material) && !(element is ProjectInfo)) { if (binding != null) { TypeBinding typeBinding = binding as TypeBinding; if (typeBinding == null) { throw new Exception("Parameter with this definition already exists and is bound to instances. It cannot be bound to the type at the same time"); } foreach (Category cat in categoriesForParam) { typeBinding.Categories.Insert(cat); } bindOK = bindingMap.ReInsert(myDefinition, binding, group); return(bindOK); } else { binding = application.Create.NewTypeBinding(categoriesForParam); } } else { if (binding != null) { InstanceBinding instBinding = binding as InstanceBinding; if (instBinding == null) { throw new Exception("Parameter with this definition already exists and is bound to types. It cannot be bound to the instance at the same time"); } foreach (Category cat in categoriesForParam) { instBinding.Categories.Insert(cat); } bindOK = bindingMap.ReInsert(myDefinition, binding, group); return(bindOK); } else { binding = application.Create.NewInstanceBinding(categoriesForParam); } } // Bind the definitions to the document bindOK = bindingMap.Insert(myDefinition, binding, group); return(bindOK); }