I am a beginner in Revit Api and trying to keep up with the upcoming project which relates to manipulating extensible storage. I have received an example code from a senior dev that try to get the extensible storage from an element as follow:
// _schema is known
Entity ent = element.GetEntity(_schema);
if (ent?.Schema != null)
{
// code to retrieve extensible storage here
// produce correct result
}
and I try to replace the snip set with my amateur code:
Entity ent = element.GetEntity(_schema);
if (ent != null && ent.IsValidObject)
{
// code to retrieve extensible storage here
// my code produces incorrect results
}
What are the differences between these 2 snip set? if I retrieve the entity using a certain schema, then the entity.Schema must return the same schema, is that correct? why do I have to check the Schema of the entity again to get the correct result? Thank you all for your time. Your answer will help me a great deal in my upcoming project.