Removing All/1 Property from the DatabaseSummaryInfoBuilder CustomPropertyTable

Removing All/1 Property from the DatabaseSummaryInfoBuilder CustomPropertyTable

Anonymous
Not applicable
1,119 Views
2 Replies
Message 1 of 3

Removing All/1 Property from the DatabaseSummaryInfoBuilder CustomPropertyTable

Anonymous
Not applicable

I'm attempting to remove Custom properties from a drawing like so

 

public static void RemoveCustomProperty(this Database db, string key)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            custProps.Remove(key);
        }

and 

 

public static void RemoveCustomProperties(this Database db)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            custProps.Clear();
        }

However they don't seem to work and I keep running into a deadend.

 

Am i missing something silly?? - Thanks for any help

0 Likes
Accepted solutions (1)
1,120 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

You need to overwrite the summary info after editing the dictionary.

 

        public static void RemoveCustomProperty(this Database db, string key)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            custProps.Remove(key);
            db.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();
        }

 

        public static void RemoveCustomProperties(this Database db)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            custProps.Clear();
            db.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();
        }

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3

Anonymous
Not applicable
Thanks, kind of assumed it was something silly - Sorry it took me a while to get around to test this. Thanks!!
0 Likes