# More extensible storage confusion :D

**URL:** <https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019>\
**Category:** Developers\
**Tags:** revit, python\
**Created:** [May 15, 2024, 11:46am UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019 "2024-05-15T11:46:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [May 15, 2024, 11:46am UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/1 "2024-05-15T11:46:30Z")

</div>

I’ve set my field ‘i1’ to have a string parameter which is “20, 20, 32, 68” as you can see at index[1] on the first Python codeblock.

I’m wanting to read the same field’s parameter in the next codeblock… But as you can see it’s magically empty!

I tried adding some pass through nodes (delay) but that didn’t help.  
What/ how/ why?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/e/3e883d8d7fcd37a8d4a413ab79fce706d6908717.png)

---

<div class="post-metadata">

**Author:** ![Brendan\_Cassidy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/brendan_cassidy/32/7685_2.png) [@Brendan\_Cassidy](https://forum.dynamobim.com/u/Brendan_Cassidy)\
**Post date:** [May 15, 2024, 11:58am UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/2 "2024-05-15T11:58:15Z")

</div>

You will need to show more of the script and code to be able to get some help. But i will ask is the first set of notes applying a change into review before you then do something else later on?

If yes then you need to save the transaction and re-get the data out afterwards, or better is to follow that data into the next nodes going forward.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [May 15, 2024, 11:59am UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/3 "2024-05-15T11:59:53Z")

</div>

Ah… so I have to commit it…

Ty 🙂

Only started playing with it this week… steep learning curve and very little documentation in Python!

EDIT… wait… isn’t setting committing it?  
Or does it have to be applied to an object in Revit to ‘fix’ it?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [May 15, 2024, 1:35pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/4 "2024-05-15T13:35:52Z")

</div>

> [@Alien](#):
>
> isn’t setting committing it?

The commit is the command actually running in Revit. Setting the value in python just “sets up” the API to run those commands once the transaction happens in Revit. Because Dynamo automatically wraps everything into a single transaction (commit), the set and read happen at the same time. So the value hasn’t actually been changed in Revit when it’s being read. A second transaction ensures that the value gets set _and_ committed before the second transaction begins the read process.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [May 15, 2024, 2:19pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/5 "2024-05-15T14:19:32Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/f/bff97fa093fa5638b85aeeee78a3f5675797285f.png)

I am setting my entities in the “Fields populate” python block

I am trying to read my entities in “Fields read” python block.

Code from first block below:

* * *

```auto
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
clr.AddReference('RevitAPIUI')

from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import ObjectType
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System

Series = "68"
schemaId = IN[1][2]

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
TransactionManager.Instance.EnsureInTransaction(doc)
schema = ExtensibleStorage.Schema.Lookup(schemaId)
entity = ExtensibleStorage.Entity(schema)

#Read the first field to find out what index there is a blank field
#Add the series number to the end of the first field's string (comma seperated)

entity.Set(schema.GetField("i1"),"20, 20, 32") #test set 

x = entity.Get[str](schema.GetField("i1")) #Get the contents of the first field
SeriesList = [entry.strip() for entry in x.split(',')]
SeriesCount = len(SeriesList) 

SeriesList.append(Series)
SeriesListAsString = ', '.join(SeriesList)

# Re-write the first field with the updated series added
entity.Set(schema.GetField("i1"), SeriesListAsString)

doc.ProjectInformation.SetEntity(entity) # store the entity in the document

y = entity.Get[str](schema.GetField("i1"))

OUT = x, SeriesCount, y, True

```

So I’ve set it to project information (I think)…  
The output looks fine.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/b/dbc191e82eaea1196cb12bf7b59148e6c7a424fd.png)

Yet, if I try to extract the entity in the next Python window I get a blank.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/4/d445be016915a1d8396b43b8912227d954b8f504.png)

I tried closing the dynamo graph and testing to see if the schema had written in a new dynamo graph and I got:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d69d4110c97acb11d468495c6b10c11be91e050d.png)

So the schema is created and the fields exist… I just don’t seem to be able to “save” the fields.

I also tried to write the schema to a sheet but got an error that Sheet has no attribute “SetEntity”

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 15, 2024, 2:51pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/6 "2024-05-15T14:51:19Z")

</div>

I get that this is a toy problem, but one would never do this.

Items packed into extensible storage are already in memory, so rather than setting the value and then instantly getting the value you’d just pull the value which you already know.

Your ‘get’ should be a separate graph entirely, likely run a minute (hour, day, week, month, year, decade) later.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [May 15, 2024, 2:53pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/7 "2024-05-15T14:53:48Z")

</div>

Surely it shouldn’t matter if I do it 1 minute later or 1 year later?

That field is coming back blank, so it’s not writing?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 15, 2024, 3:01pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/8 "2024-05-15T15:01:17Z")

</div>

You haven’t committed the data into the field until the Dynamo instance finishes running. There isn’t any data until then.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [May 15, 2024, 3:10pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/9 "2024-05-15T15:10:32Z")

</div>

OK, so I ran the node to set… The one with the output.

Closed that Dynamo graph and opened a new one:

All this is doing is reading the first field:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/c/3c36626b4faa5efac744c950eb6fb274815a2fa1.png)

But it’s not written anything to the first field?

Or do I have to shut Dynamo and try?

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [May 15, 2024, 3:25pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/10 "2024-05-15T15:25:39Z")

</div>

Ah… I was trying to call the entity in the wrong way.

```auto
    sheet_element = doc.GetElement(ElementId(sheet.Id))
    entity = sheet_element.GetEntity(schema)
    if entity.IsValid():
        # Verify the contents of the field
        verified_value = entity.Get[str](schema.GetField("i1"))

```

Seems I have to call it from the object, not just grab the schema.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [May 15, 2024, 4:50pm UTC](https://forum.dynamobim.com/t/more-extensible-storage-confusion-d/101019/11 "2024-05-15T16:50:07Z")

</div>

> [@Alien](#):
>
> Seems I have to call it from the object, not just grab the schema.

Correct. This is why pretty much every object type in Revit.DB inherits the ‘entity’ method. 🙂
