Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm just now exploring Revit's Extensible Storage and I decided to try creating a DataStorage element to store some project data. I can create the DataStorage element and the Entity just fine, but when I try applying the entity the DocumentCreatedEvent closes without committing the transaction. There shouldn't be an issue doing this in the event I'm using, right?
I'll paste some of my code below, but just as a reference I used Victor's "Effortless Extensible Storage" that Jeremy talks about here. (So if the code I pasted looks good, I probably broke something else).
using (Transaction t = new Transaction(doc, "Create data storage"))
{
t.Start();
DataStorage dsProjectData = DataStorage.Create(doc);
ProjectData entProjectData = new ProjectData();
entProjectData.Author = Environment.UserName;
entProjectData.DateCreated = DateTime.Now;
entProjectData.RoomCount = 0;
dsProjectData.SetEntity(entProjectData);
t.Commit();
}
[Schema("FB0EE2DE-06EB-4A0E-8C76-11B906F40B16", "Project Data")]
public class ProjectData : IRevitEntity
{
#region Creation Info
/// <summary>
/// The user who created the project
/// </summary>
[Field]
public string Author { get; set; }
/// <summary>
/// The date the project was created
/// </summary>
[Field]
public DateTime DateCreated { get; set; }
#endregion
/// <summary>
/// Total number of rooms in the project
/// </summary>
[Field]
public int RoomCount { get; set; }
}
Solved! Go to Solution.