Hello,
I want to use an extensible storage.
How do I know if it already exists in the current document (I know the GUID)?
Thank you.
Philippe.
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Hi @pmeigneux,
Have you looked at the examples in the SDK?
What have you tried so far?
Cheers,
-Matt
Hi Matt,
Yes, I'm find :
/// <summary> /// Create a data structure, attach it to a wall, /// populate it with data, and retrieve the data /// back from the wall /// </summary> public 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" ) ); // allow anyone to read the object schemaBuilder.SetReadAccessLevel( AccessLevel.Public ); // restrict writing to this vendor only schemaBuilder.SetWriteAccessLevel( AccessLevel.Vendor ); // required because of restricted write-access schemaBuilder.SetVendorId( "ADSK" ); // 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." ); schemaBuilder.SetSchemaName( "WireSpliceLocation" ); Schema schema = schemaBuilder.Finish(); // register the Schema object // create an entity (object) for this schema (class) Entity entity = new Entity( schema ); // get the field from the schema Field fieldSpliceLocation = schema.GetField("WireSpliceLocation" ); entity.Set<XYZ>( fieldSpliceLocation, dataToStore, DisplayUnitType.DUT_METERS ); // set the value for this entity 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(); }
But How define a variable schema when i cannot create a new Schema ?
Philippe.
The API documents return quite a few hits for the search word 'schema'. I can see one that lists the loaded schemas, another that looks for one given a GUID.
Have you perused the search results?
Cheers,
-Matt
Dear Philippe,
Thank you for your query.
Glad to hear you are looking into this important, useful and powerful functionality.
Many thanks to Matt for all the help you already provided!
In addition to Matt’s suggestions, The Building Coder defines a dedicated topic group for extensible storage:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.23
Philippe, you answer is already answered there, several times over.
As far as I can tell, the extensible storage helper class JtNamedGuidStorage described in the post on Named Guid Storage for Project Identification shows how to implement what you are asking for.
I would be surprised if you run into any relevant questions on extensible storage that have not already been answered and published in that collection.
If you do, I will certainly add them!
Looking forward to seeing what you come up with 🙂
I hope this helps.
Best regards,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.