<?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: Set Dimension type Color in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9847603#M30667</link>
    <description>&lt;P&gt;Sorry for the late respond, I already try changing the dimension type color through Revit interface and get the same result. Since I don't know the formula to calculate the Revit color int value, I have to use the System.Drawing.Color methods FromArgb() and ToArgb() in hope that it will have the same formula as Revit color.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5661631"&gt;@naveen.kumar.t&lt;/a&gt;&amp;nbsp;has point me to the correct direction and the help from one of your post, I can achieve what I want. However, that also proven that the int value for System.Drawing.Color and Autodesk.Revit.DB.Color are calculate differently. I can take a fuzzy guess that the parameter (R, G, B) are taken in reversed order so that the int value for Red and Blue are inter-changed (this is what I received when I set the alpha/opaque to 0).&lt;/P&gt;</description>
    <pubDate>Thu, 05 Nov 2020 11:15:43 GMT</pubDate>
    <dc:creator>longt61</dc:creator>
    <dc:date>2020-11-05T11:15:43Z</dc:date>
    <item>
      <title>Set Dimension type Color</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9845200#M30663</link>
      <description>&lt;P&gt;I am using Revit Api 2019.2 and have encountered this strange problem.&lt;/P&gt;&lt;P&gt;I tried to duplicate a dimension type and assign a red color to it as follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// I tried to set red color to dimension type
System.Drawing.Color sysColor = System.Drawing.Color .FromArgb(255, 0,0);
int intValue = sysColor.ToArgb();

dimType = originalDimType.Duplicate(typeName) as DimensionType;
Parameter param = dimType.get_Parameter(BuiltInParameter.LINE_COLOR);
param.Set(intValue); // the value is 16711680, which is blue&lt;/LI-CODE&gt;&lt;P&gt;And I get a new dimension type with blue color.&lt;/P&gt;&lt;P&gt;However if I hardcode the int value as 255, I get a red color&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;param.Set(255); // red color&lt;/LI-CODE&gt;&lt;P&gt;I don't understand what happened here and why there is a difference between System.Drawing.Color and Autodesk.Revit.DB.Color converting RGB value to int value?&lt;/P&gt;&lt;P&gt;How does this conversion process happen? Is there an other way to set line color for dimension type using Color / RGB value directly? Thank you all very much.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 13:22:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9845200#M30663</guid>
      <dc:creator>longt61</dc:creator>
      <dc:date>2020-11-04T13:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Set Dimension type Color</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9845308#M30664</link>
      <description>&lt;P&gt;I would suggest setting various different colours manually in the user interface and using RevitLookup to analyse what results that has and how the different colours are represented in the database. Then all will become clear. Please let us know what you find out. Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 14:03:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9845308#M30664</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-11-04T14:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Set Dimension type Color</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9845377#M30665</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4859081"&gt;@longt61&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;try using this below code&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;DimensionType originalType;
                DimensionType duplicateType = originalType.Duplicate("duplicated dimension type name") as DimensionType;
                Parameter colorParam = duplicateType.get_Parameter(BuiltInParameter.LINE_COLOR);
                if(colorParam!=null)
                {
                    System.Drawing.Color sysColor = System.Drawing.Color.FromArgb(255, 0,0 );
                    int intColor = GetLineColorFromSystemColor(sysColor);
                    colorParam.Set(intColor);
                }&lt;/LI-CODE&gt;
&lt;P&gt;Method&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;private int GetLineColorFromSystemColor(System.Drawing.Color color)
        {
             return (int)color.R + (int)color.G * (int)Math.Pow(2, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; + (int)color.B * (int)Math.Pow(2, 16);
        } &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the method(GetLineColorFromSystemColor()) mentioned in this below link&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2018/02/changing-text-colour.html?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+typepad%2Fthe-building-coder+%28The+Building+Coder%29" target="_blank" rel="noopener"&gt;https://thebuildingcoder.typepad.com/blog/2018/02/changing-text-colour.html?utm_source=feedburner&amp;amp;utm_medium=feed&amp;amp;utm_campaign=Feed%3A+typepad%2Fthe-building-coder+%28The+Building+Coder%29&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 14:27:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9845377#M30665</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2020-11-04T14:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Set Dimension type Color</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9847574#M30666</link>
      <description>&lt;P&gt;Thank yo for the helpful information. With the provided formula, I can create the Int value for the color and compare them.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 11:06:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9847574#M30666</guid>
      <dc:creator>longt61</dc:creator>
      <dc:date>2020-11-05T11:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Set Dimension type Color</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9847603#M30667</link>
      <description>&lt;P&gt;Sorry for the late respond, I already try changing the dimension type color through Revit interface and get the same result. Since I don't know the formula to calculate the Revit color int value, I have to use the System.Drawing.Color methods FromArgb() and ToArgb() in hope that it will have the same formula as Revit color.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5661631"&gt;@naveen.kumar.t&lt;/a&gt;&amp;nbsp;has point me to the correct direction and the help from one of your post, I can achieve what I want. However, that also proven that the int value for System.Drawing.Color and Autodesk.Revit.DB.Color are calculate differently. I can take a fuzzy guess that the parameter (R, G, B) are taken in reversed order so that the int value for Red and Blue are inter-changed (this is what I received when I set the alpha/opaque to 0).&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 11:15:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/set-dimension-type-color/m-p/9847603#M30667</guid>
      <dc:creator>longt61</dc:creator>
      <dc:date>2020-11-05T11:15:43Z</dc:date>
    </item>
  </channel>
</rss>

