<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HOW TO MODIFY FIELD DATA THROUGH CODE. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11465497#M11492</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use these extension methods.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        /// &amp;lt;summary&amp;gt;
		/// Gets the value of a custom property.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="key"&amp;gt;Property key.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;The property value or null if not found.&amp;lt;/returns&amp;gt;
        public static string GetCustomProperty(this Database db, string key)
        {
            DatabaseSummaryInfoBuilder sumInfo = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = sumInfo.CustomPropertyTable;
            return ((string)custProps[key]).Trim();
        }

        /// &amp;lt;summary&amp;gt;
		/// Gets the Database properties.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;A dictionary containing the custom properties.&amp;lt;/returns&amp;gt;
        public static Dictionary&amp;lt;string, string&amp;gt; GetCustomProperties(this Database db)
        {
            Dictionary&amp;lt;string, string&amp;gt; result = new Dictionary&amp;lt;string, string&amp;gt;();
            IDictionaryEnumerator dictEnum = db.SummaryInfo.CustomProperties;
            while (dictEnum.MoveNext())
            {
                DictionaryEntry entry = dictEnum.Entry;
                result.Add((string)entry.Key, ((string)entry.Value).Trim());
            }
            return result;
        }

        /// &amp;lt;summary&amp;gt;
		/// Sets the value of an existing property or create it if it didn't exist.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="key"&amp;gt;Property key.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="value"&amp;gt;Property value.&amp;lt;/param&amp;gt;
        public static void SetCustomProperty(this Database db, string key, string value)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            if (custProps.Contains(key))
                custProps[key] = value;
            else
                custProps.Add(key, value);
            db.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();
        }

        /// &amp;lt;summary&amp;gt;
		/// Sets the values of existing properties or create those which didn't exist.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="values"&amp;gt;Key/Value pairs for the properties.&amp;lt;/param&amp;gt;
        public static void SetCustomProperties(this Database db, params KeyValuePair&amp;lt;string, string&amp;gt;[] values)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            foreach (KeyValuePair&amp;lt;string, string&amp;gt; pair in values)
            {
                string key = pair.Key;
                if (custProps.Contains(key))
                    custProps[key] = pair.Value;
                else
                    custProps.Add(key, pair.Value);
            }
            db.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();
        }&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 06 Oct 2022 10:01:50 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2022-10-06T10:01:50Z</dc:date>
    <item>
      <title>HOW TO MODIFY FIELD DATA THROUGH CODE.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11465442#M11491</link>
      <description>&lt;P&gt;I have added Data to Field Data. How can I get those values Programatically?&lt;/P&gt;&lt;P&gt;Any help will be great. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for reference, I have attached the image and link:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Field data.PNG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1124186iB46A501B135343F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Field data.PNG" alt="Field data.PNG" /&gt;&lt;/span&gt;&lt;A title="How to use fields " href="https://allaboutcad.com/tutorial-use-fields-for-titleblock-text/" target="_blank" rel="noopener"&gt;https://allaboutcad.com/tutorial-use-fields-for-titleblock-text/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 09:35:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11465442#M11491</guid>
      <dc:creator>nikhilsTHSR5</dc:creator>
      <dc:date>2022-10-06T09:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO MODIFY FIELD DATA THROUGH CODE.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11465497#M11492</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use these extension methods.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        /// &amp;lt;summary&amp;gt;
		/// Gets the value of a custom property.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="key"&amp;gt;Property key.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;The property value or null if not found.&amp;lt;/returns&amp;gt;
        public static string GetCustomProperty(this Database db, string key)
        {
            DatabaseSummaryInfoBuilder sumInfo = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = sumInfo.CustomPropertyTable;
            return ((string)custProps[key]).Trim();
        }

        /// &amp;lt;summary&amp;gt;
		/// Gets the Database properties.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;A dictionary containing the custom properties.&amp;lt;/returns&amp;gt;
        public static Dictionary&amp;lt;string, string&amp;gt; GetCustomProperties(this Database db)
        {
            Dictionary&amp;lt;string, string&amp;gt; result = new Dictionary&amp;lt;string, string&amp;gt;();
            IDictionaryEnumerator dictEnum = db.SummaryInfo.CustomProperties;
            while (dictEnum.MoveNext())
            {
                DictionaryEntry entry = dictEnum.Entry;
                result.Add((string)entry.Key, ((string)entry.Value).Trim());
            }
            return result;
        }

        /// &amp;lt;summary&amp;gt;
		/// Sets the value of an existing property or create it if it didn't exist.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="key"&amp;gt;Property key.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="value"&amp;gt;Property value.&amp;lt;/param&amp;gt;
        public static void SetCustomProperty(this Database db, string key, string value)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            if (custProps.Contains(key))
                custProps[key] = value;
            else
                custProps.Add(key, value);
            db.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();
        }

        /// &amp;lt;summary&amp;gt;
		/// Sets the values of existing properties or create those which didn't exist.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="db"&amp;gt;Database the method applys to.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="values"&amp;gt;Key/Value pairs for the properties.&amp;lt;/param&amp;gt;
        public static void SetCustomProperties(this Database db, params KeyValuePair&amp;lt;string, string&amp;gt;[] values)
        {
            DatabaseSummaryInfoBuilder infoBuilder = new DatabaseSummaryInfoBuilder(db.SummaryInfo);
            IDictionary custProps = infoBuilder.CustomPropertyTable;
            foreach (KeyValuePair&amp;lt;string, string&amp;gt; pair in values)
            {
                string key = pair.Key;
                if (custProps.Contains(key))
                    custProps[key] = pair.Value;
                else
                    custProps.Add(key, pair.Value);
            }
            db.SummaryInfo = infoBuilder.ToDatabaseSummaryInfo();
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Oct 2022 10:01:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11465497#M11492</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-10-06T10:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: HOW TO MODIFY FIELD DATA THROUGH CODE.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11472055#M11493</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you it worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 05:18:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-modify-field-data-through-code/m-p/11472055#M11493</guid>
      <dc:creator>nikhilsTHSR5</dc:creator>
      <dc:date>2022-10-10T05:18:36Z</dc:date>
    </item>
  </channel>
</rss>

