Revit 2015 .NET API eStorage
I have two questions inregards to estorage\
1. How to do a create a storage to store information without associating to an entity.
I wanted to have some general infomraiton stored.
// Create a data structure, attach it to a wall, populate it with data, and retrieve the data back from the wall void StoreDataInWall(Wall wall, XYZ dataToStore) { Transaction createSchemaAndStoreData = new Transaction(wall.Document, "tCreateAndStore"); createSchemaAndStoreData.Start(); SchemaBuilder schemaBuilder = new SchemaBuilder(new Guid("720080CB-DA99-40DC-9415-E53F280AA1F0")); schemaBuilder.SetReadAccessLevel(AccessLevel.Public); // allow anyone to read the object schemaBuilder.SetWriteAccessLevel(AccessLevel.Vendor); // restrict writing to this vendor only schemaBuilder.SetVendorId("ADSK"); // required because of restricted write-access schemaBuilder.SetSchemaName("WireSpliceLocation"); // create a field to store an XYZ FieldBuilder fieldBuilder = schemaBuilder.AddSimpleField("WireSpliceLocation", typeof(XYZ)); fieldBuilder.SetUnitType(UnitType.UT_Length); fieldBuilder.SetDocumentation("A stored location value representing a wiring splice in a wall."); Schema schema = schemaBuilder.Finish(); // register the Schema object Entity entity = new Entity(schema); // create an entity (object) for this schema (class) // get the field from the schema Field fieldSpliceLocation = schema.GetField("WireSpliceLocation"); // set the value for this entity entity.Set<XYZ>(fieldSpliceLocation, dataToStore, DisplayUnitType.DUT_METERS); wall.SetEntity(entity); // store the entity in the element // get the data back from the wall Entity retrievedEntity = wall.GetEntity(schema); XYZ retrievedData = retrievedEntity.Get<XYZ>(schema.GetField("WireSpliceLocation"), DisplayUnitType.DUT_METERS); createSchemaAndStoreData.Commit(); }
based on this example from dev guide.
2. If i need to create a eStore which can be accessed only by using my vendor id and application.
what settings should that value for read and write.
When I specify a vendor ID its give me an error.
So If I specificy vendor ID in it other developer cannot edit or delete those values right?
Thanks for your help.
You must store your data in an entity, there is no getting away from that. If you mean that you don't want to store your data in a transient element so that it is protected from user deletion / modification, then you have a couple of options.
Option 1: Use a system element that is always present, yet can't be deleted using the user interface. The Document.ProjectInformation element fits this need nicely. This could get a little messy in a worksharing environment though, as it will be used frequently by users to update project parameters and other add-ins (even those used by other worksharing users) could have the same idea as you and want constant access for storing thier own data. I don't advise this method if you need to support a worksharing environment.
Option 2: Use a DataStorage element, these are API specific elements with the sole purpose of having entities stored within them, they are invisible to the user interface so are unlikely (impossible maybe?) to be deleted by a user and because you have created them they are unlikely to be hijacked by other add ins. Once created they can be easily found again using a class filter and with a little management code you could designate one instance as a singleton if that is what you are after.
In relation to your problem with the schema not allowing you to read it. You need to make sure that the vendor id used to create the schema is the same as entered into the manufest file used to load your command / application.