- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Short: After progmatically updating the List Items in the List Definition of a Property Definition, the items in the Style Manager are correct, but the list of available values either does not update or shows *Error getting value*. I'm using the same code and sometimes get one and sometimes the other result.
Mostly, it helps to close the Properties Panel (to click on x, not just hide it) and reopen it and then the updated values show.
Sometimes it doesn't and then I have to Remove Property Set in GUI and then re-add it.
What am I missing? Is there a way to progmatically update/refresh/reload the PROPERTIES > Extended Data tab?
Photos:
I'm modifying the Property Set Definition called NVSurfaceStyles.
Property Definition called SurfaceStyle has a source ListDefinition SurfaceStyles-NV.
All is OK in Style Manager.
The code that I'm using:
using Autodesk.Aec.DatabaseServices;
using Autodesk.Aec.PropertyData.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using System.Collections.Generic;
using ObjectId = Autodesk.AutoCAD.DatabaseServices.ObjectId;
Database _db = Application.DocumentManager.MdiActiveDocument.Database;
internal void ImportStyleNamesToPropertySetListDefinitions()
{
ObjectId propertySetDefinitionId = ObjectId.Null;
List<string> stylesToAdd = new List<string>();
using (var tr = _db.TransactionManager.StartTransaction())
{
// open property set definition
var propSetDef = tr.GetObject(propertySetDefinitionId, OpenMode.ForWrite) as PropertySetDefinition;
// for each of the definitions in it
foreach (PropertyDefinition propDefinition in propSetDef.Definitions)
{
// go by name
if (propDefinition.Name == "SurfaceStyle")
{
if (propDefinition.DataType == Autodesk.Aec.PropertyData.DataType.List)
{
// get source list definition id
var listDefinitionId = propDefinition.ListDefinitionId;
// open this list definition
var listDefinition = tr.GetObject(listDefinitionId, OpenMode.ForWrite) as ListDefinition;
// add style name items to it
foreach (string styleName in stylesToAdd)
listDefinition.AddListItem(styleName);
}
}
}
tr.Commit();
}
protected void ClearPropertyListDefinitions(ObjectId propertySetDefinitionId)
{
using (var tr = _db.TransactionManager.StartTransaction())
{
// open property set definition
var propSetDef = tr.GetObject(propertySetDefinitionId, OpenMode.ForRead) as PropertySetDefinition;
// for each of the definitions in it
foreach (PropertyDefinition propDefinition in propSetDef.Definitions)
{
// find correct property definitions
if (propDefinition.Name == "SurfaceStyle")
{
if (propDefinition.DataType == Autodesk.Aec.PropertyData.DataType.List)
{
// get source list definition id
var listDefinitionId = propDefinition.ListDefinitionId;
// open source list definition
var listDefinition = tr.GetObject(listDefinitionId, OpenMode.ForWrite) as ListDefinition;
// clear items that are not "-"
ObjectIdCollection itemIds = listDefinition.GetListItems();
for (int i = itemIds.Count - 1; i >= 0; i--)
{
var item = tr.GetObject(itemIds[i], OpenMode.ForWrite) as ListItem;
if (item.Name != "-")
listDefinition.DeleteListItem(itemIds[i]);
}
}
}
}
tr.Commit();
}
Solved! Go to Solution.