static void CheckNecessarySharedParameters(Document doc) { // iterate the procedure over all the shared parameters in the document SharedParametersManager sharedParamMng = new SharedParametersManager(doc); if (!sharedParamMng.DoesParameterExist(SILL_HEIGHT)) { List <BuiltInCategory> categories = new List <BuiltInCategory> { BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows }; sharedParamMng.CreateSharedParameter( SILL_HEIGHT, ParameterType.Text, categories, BuiltInParameterGroup.PG_CONSTRAINTS, true, false, true, "Custom", true, new Guid("CB9AF2A5-BA75-404E-A462-0AAB7C3297A1")); sharedParamMng.CanVaryBtwGroups(SILL_HEIGHT, true); } if (!sharedParamMng.DoesParameterExist(HEAD_HEIGHT)) { List <BuiltInCategory> categories = new List <BuiltInCategory> { BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows }; sharedParamMng.CreateSharedParameter( HEAD_HEIGHT, ParameterType.Text, categories, BuiltInParameterGroup.PG_CONSTRAINTS, true, false, true, "Custom", true, new Guid("492127E8-04F4-47A2-B0AB-8ADDD61ABDCF")); sharedParamMng.CanVaryBtwGroups(HEAD_HEIGHT, true); } }
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { System.Diagnostics.Trace.Listeners. Add(new System.Diagnostics.EventLogTraceListener("Application")); Autodesk.Revit.UI.UIDocument uidoc = commandData.Application.ActiveUIDocument; Autodesk.Revit.DB.Document doc = uidoc.Document; try { CreateSharedParamWin hwnd = new CreateSharedParamWin(doc); hwnd.ShowDialog(); if (hwnd.ParameterName == null || hwnd.ParameterName.Length == 0) { return(Autodesk.Revit.UI.Result.Cancelled); } SharedParametersManager spManager = new SharedParametersManager(doc); spManager.CreateSharedParameter( hwnd.ParameterName, hwnd.ParameterType, new List <BuiltInCategory> { hwnd.Category }, hwnd.ParameterGroup, hwnd.IsInstance, hwnd.IsModifiable, hwnd.IsVisible, hwnd.GroupName ); if (hwnd.CanVaryBtwGroups) { spManager.CanVaryBtwGroups(hwnd.ParameterName, true); } return(Autodesk.Revit.UI.Result.Succeeded); } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { return(Autodesk.Revit.UI.Result.Cancelled); } catch (System.Exception ex) { Autodesk.Revit.UI.TaskDialog.Show("Exception", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); return(Autodesk.Revit.UI.Result.Failed); } }