The Revit API 2012 provides an official way to extend the Element data now. In the old days, we could only create some cumbersome invisible parameters and attach them to the elements where we want to store some extra data. Now the Extensible Storage API can directly address so basic a need for us and has much power.
However, as introduced and demonstrated before, unnecessary complexities, impositions, redundancies and inconsistencies are here and there. In case any of those points as mentioned repeatedly slip out of our minds, the data storage or read back would just fail. In addition, the out of box supported data types are just a few, far less than enough.
Fortunately, deleting extensible data is easy enough.
using (Transaction trans = new Transaction(CachedDoc, "RemoveDataFrom"))
{
trans.Start();
Reference picked = CachedUiApp.ActiveUIDocument.Selection.PickObject(ObjectType.Element, "Pick the element to remove the data from");
Schema sch = Schema.Lookup(new Guid("DA4AAE5A-4EE1-45A8-B3E8-F790C84CC44F"));
CachedDoc.GetElement(picked).DeleteEntity(sch);
trans.Commit();
}
As can be seen above, only two stepps are necessary. Looking up the schema based on its GUID from the model first and remove the schema through the DeleteEntity() method next. The good thing is that the DeleteEntity will not complain anything if the Schema/Entity is not there.
The Revit Addin Wizard (RevitAddinWizard) provides a coder to help generate the super easy and cool Revit Data Operator and/or the Revit Data Extensioner as demonstrated in various aspects before.
Recent Comments