Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How retrieve already exist Extensible Storage ?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
pmeigneux
1908 Views, 4 Replies

How retrieve already exist Extensible Storage ?

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.

4 REPLIES 4
Message 2 of 5
matthew_taylor
in reply to: pmeigneux

Hi @pmeigneux,

Have you looked at the examples in the SDK?

What have you tried so far?

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 5
pmeigneux
in reply to: matthew_taylor

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.

 

 

Message 4 of 5
matthew_taylor
in reply to: pmeigneux

@pmeigneux,

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


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 5 of 5
jeremytammik
in reply to: pmeigneux

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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report