Delete custom FamilyParameter

By Augusto Goncalves (@augustomaia)

Here is a quick code showing how to delete a family parameter using API. It’s not on the “obvious” way, but it’s possible.

UIApplication uiapp = commandData.Application;UIDocument uidoc = uiapp.ActiveUIDocument;Application app = uiapp.Application;Document doc = uidoc.Document; if (doc.IsFamilyDocument){  FamilyParameter famParam = doc.FamilyManager.get_Parameter("Custom_Param_Name");  if (famParam != null)  {    Transaction trans = new Transaction(doc, "Erase custom family parameter");    trans.Start();    //doc.FamilyManager.Parameters.Erase(famParam); // cannot erase, read-only    //doc.ParameterBindings.Remove(famParam.Definition); // not available on fam doc    doc.Delete(famParam.Id); // this works!    trans.Commit();  }}

Comments

7 responses to “Delete custom FamilyParameter”

  1. Hi Augusto, I believe that it is still not possible to truly delete a Shared Parameter (i.e. including the internal GUID). To test the above code: Add a shared Parameter, delete Shared Parameter from the family (as above), rename the Shared Parameter in the txt file (keep old GUID), add the new Shared Parameter. The new Parameter will have the name of the deleted parameter, not the new name. If you can come up with an example to rename a shared Parameter you will become the Grande Poobah of Revit API support. Regards, Dale

  2. Sound like a good challenge Dale :-) let me investigate if is possible
    Cheers,
    Augusto Goncalves

  3. Hi Augusto, One day short of two years, is that enough time??? Cheers, Dale

  4. oops, US date format tricked me.

  5. Let me check if a colleague can help you, currently I’m not working with Revit API. Sorry I missed this :-)

  6. HI Dale, you’re right! Thanks for the input.

  7. I’d like to thank the author for writing such an insightful and informative blog post about parameters that is not just useful to the readers but also revealing.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading