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.
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.
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:
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.
Yet, if I try to extract the entity in the next Python window I get a blank.
I tried closing the dynamo graph and testing to see if the schema had written in a new dynamo graph and I got:
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.
Ah… I was trying to call the entity in the wrong way.
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.