Hi Alvindragon
My app delete share parameters from a class (Helper) containing shared parameters list for delete, this is my code, i hope help you
private void EliminarParametros(Document doc, Autodesk.Revit.ApplicationServices.Application app)
{
foreach (KeyValuePair<string, string> elementos in Helper.Properties)
{
RawEraseSharedParameterBinding(app, doc, elementos.Key, ParameterType.Text);
}
}
public static bool RawEraseSharedParameterBinding(Autodesk.Revit.ApplicationServices.Application app, Document doc, string name, ParameterType type)
{
try
{
BindingMap map = (new UIApplication(app)).ActiveUIDocument.Document.ParameterBindings;
DefinitionBindingMapIterator it = map.ForwardIterator();
it.Reset();
Definition def = null;
while (it.MoveNext())
{
if (it.Key != null && it.Key.Name.Equals(name))// && type.Equals(it.Key.ParameterType))
{
def = it.Key;
break;
}
}
if (def != null)
{
Transaction transaction = new Transaction(doc, "Update Revit Type");
transaction.Start();
map.Remove(def);
transaction.Commit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return false;
}
public class Helper
{
public static string Prefix = "eBIM";
public static UIDocument ActiveUIDocument;
public static UIApplication Aplication;
public static Dictionary<string, string> Properties = new Dictionary<string, string>()
{
{ "Param1"," Generales"},
{ "Param2"," Generales"},
{ "Param3"," Texto"},
{ "Param4"," Texto"}
};
}
In your button or event, etc, call the method
Autodesk.Revit.ApplicationServices.Application app = (Autodesk.Revit.ApplicationServices.Application)sender;
Document doc = e.Document;
EliminarParametros (doc,app);
Good luck!
Did you ever resolve this? I'm also having a problem deleting a project (non-shared) parameter. Is it not possible?
You need to find the associated ParameterElement. If you delete that element, the projectparameter will also be removed.
string parametername = "testparameter"; IEnumerable<ParameterElement> _params = new FilteredElementCollector(doc) .WhereElementIsNotElementType() .OfClass(typeof(ParameterElement)) .Cast<ParameterElement>(); ParameterElement projectparameter = null; foreach(ParameterElement pElem in _params) { if (pElem.GetDefinition().Name.Equals(parametername)) { projectparameter = pElem; break; } } if (projectparameter==null) return; using (Transaction t = new Transaction(doc,"remove projectparameter")) { t.Start(); doc.Delete(projectparameter.Id); t.Commit(); }
Can't find what you're looking for? Ask the community or share your knowledge.