So in my situation I extra object information in three places: Object Data, XData, and Extension Dictionaries.
The Property Sets are down in an Extension Dictionary.
DBObject dbObject = pcc.TheTransaction.GetObject( dbId, OpenMode.ForRead );
ObjectId dbIdExtDict = dbObject.ExtensionDictionary;
if( !dbIdExtDict.IsValid )
{
Acad.Report( "Object has no extension dictionary." );
break;
}
DBDictionary dbExtDict = pcc.TheTransaction.GetObject( dbIdExtDict, OpenMode.ForRead ) as DBDictionary;
if( dbExtDict == null )
{
Acad.Report( "Object has no extension dictionary." );
break;
}
Acad.Report( "Extension dictionary:" );
ReportDictionary( pcc, dbExtDict, 0 );
Acad.Report( "\n" );
pcc.TheTransaction is just a drawing transaction. Acad.Report just burps some output to the command window.
Down inside ReportDictionary I go through the dictionaries looking for the PropertySet one.
public static void ReportDictionary( CaddDB.Context.PublisherCommand pcc, DBDictionary dbDictionary, int level )
{
do
{
try
{
string indent = " ";
for( int i = 0; i < level; i++ )
indent += " ";
int n = 0;
foreach( DBDictionaryEntry ent in dbDictionary )
{
DBObject dbEntry = pcc.TheTransaction.GetObject( ent.Value, OpenMode.ForRead, false );
if( dbEntry == null )
continue;
string type = String.Format( "({0}): ", dbEntry.GetType().ToString() );
Acad.Report( String.Format(
"{0}{1}.{2}: key: {3}; type: {4}",
indent,
level,
n++,
ent.Key,
type
) );
if( dbEntry.GetType() == typeof( Xrecord ) )
{
Xrecord xRec = dbEntry as Xrecord;
if( xRec == null )
continue;
ReportRecord( pcc, xRec, level + 1 );
continue;
}
if( dbEntry.GetType() == typeof( DBDictionary ) )
{
DBDictionary dbd = dbEntry as DBDictionary;
if( dbd == null )
continue;
ReportDictionary( pcc, dbd, level + 1 );
continue;
}
if( dbEntry.GetType() == typeof( PropertySet ) )
{
PropertySet ps = dbEntry as PropertySet;
if( ps == null )
continue;
ReportPropertySet( pcc, ps, level + 1 );
continue;
} }
}
catch( System.Exception ex )
{
Chronicle.AddException( ex );
}
}
while( false );
}
public static void ReportPropertySet( CaddDB.Context.PublisherCommand pcc, PropertySet ps, int level )
{
do
{
try
{
string indent = " ";
for( int i = 0; i < level; i++ )
indent += " ";
ObjectId idDef = ps.PropertySetDefinition;
// pcc.TheTransaction is a drawing transaction
PropertySetDefinition propSetDef = (PropertySetDefinition)pcc.TheTransaction.GetObject( idDef, OpenMode.ForRead );
PropertyDefinitionCollection propDefCol = propSetDef.Definitions;
// create a list so that it's easier to index later
PropertyDefinitionList propDefList = new PropertyDefinitionList();
foreach( PropertyDefinition propDef in propDefCol )
{
propDefList.Add( propDef );
}
PropertySetDataCollection psdc = ps.PropertySetData;
foreach( PropertySetData psd in psdc )
{
PropertyDefinition[] ies = propDefList.Where( x => x.Id == psd.Id ).ToArray();
if( ies.Count() > 0 )
{
PropertyDefinition propDef = ies[0];
Acad.Report(
$"{indent}{psd.Id}, {psd.DataType}, {propDef.Name} = {psd.GetData()}"
);
}
else
{
Acad.Report(
$"{indent}{psd.Id}, {psd.DataType}, {psd.FieldBucketId} = {psd.GetData()}"
);
}
}
}
catch( System.Exception ex )
{
Chronicle.AddException( ex );
}
}
while( false );
}
So in my example you get the value at psd.GetData(), and you could use SetData() as you like.
I hope that helps.
--dunc