<?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: Appearance Asset SetColor Method in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304104#M98795</link>
    <description>&lt;P&gt;Hello Ron,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To set color to a appearance, the appearance need satisfy two conditions:&lt;/P&gt;
&lt;P&gt;1. The appearance is not read only.&lt;/P&gt;
&lt;P&gt;2. The appearance doesn't have texture&lt;/P&gt;
&lt;P&gt;As shown in below picture, the left one has texture which is used to control the appearance color, which means the color property can't be set individually; while the right appearance can be controlled directly by color property.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CM.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/390495iC55D55553FC4128A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CM.jpg" alt="CM.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please check the code below:&lt;/P&gt;
&lt;P&gt;Public Sub SetExistingColorAppearance()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim doc As Document&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set doc = ThisApplication.ActiveDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim docAssets As Assets&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set docAssets = doc.Assets&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get the document level asset&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim appearance As Asset&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set appearance = docAssets.Item(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tobjs As TransientObjects&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tobjs = ThisApplication.TransientObjects&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If appearance.HasTexture = False And appearance.IsReadOnly = False Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim color As ColorAssetValue&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set color = appearance.Item("generic_diffuse")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color.Value = tobjs.CreateColor(255, 255, 15)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR /&gt;End Sub&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2017 09:56:39 GMT</pubDate>
    <dc:creator>JaneFan</dc:creator>
    <dc:date>2017-08-16T09:56:39Z</dc:date>
    <item>
      <title>Appearance Asset SetColor Method</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7303391#M98794</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to tweek the RGB color values of an existing Appearance Asset with the .SetColor method, but I can't get the method to actually change the RGB color values of the Asset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The .CreateColor method works well to create the local asset, per the 'Public Sub CreateSimpleColorAppearance()' routine in the Sample Code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a code fragment that uses the .SetColor method they would be willing to share or have an explanation as to how this method works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm coding in VBA&amp;nbsp;to&amp;nbsp;update&amp;nbsp;an older color change&amp;nbsp;macro&amp;nbsp;to work in Inventor 2018.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ron W.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 02:14:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7303391#M98794</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-16T02:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Appearance Asset SetColor Method</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304104#M98795</link>
      <description>&lt;P&gt;Hello Ron,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To set color to a appearance, the appearance need satisfy two conditions:&lt;/P&gt;
&lt;P&gt;1. The appearance is not read only.&lt;/P&gt;
&lt;P&gt;2. The appearance doesn't have texture&lt;/P&gt;
&lt;P&gt;As shown in below picture, the left one has texture which is used to control the appearance color, which means the color property can't be set individually; while the right appearance can be controlled directly by color property.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CM.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/390495iC55D55553FC4128A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CM.jpg" alt="CM.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please check the code below:&lt;/P&gt;
&lt;P&gt;Public Sub SetExistingColorAppearance()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim doc As Document&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set doc = ThisApplication.ActiveDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim docAssets As Assets&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set docAssets = doc.Assets&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Get the document level asset&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim appearance As Asset&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set appearance = docAssets.Item(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tobjs As TransientObjects&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tobjs = ThisApplication.TransientObjects&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If appearance.HasTexture = False And appearance.IsReadOnly = False Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim color As ColorAssetValue&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set color = appearance.Item("generic_diffuse")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; color.Value = tobjs.CreateColor(255, 255, 15)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 09:56:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304104#M98795</guid>
      <dc:creator>JaneFan</dc:creator>
      <dc:date>2017-08-16T09:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Appearance Asset SetColor Method</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304338#M98796</link>
      <description>&lt;P&gt;Hi @Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the following VBA code to update color. Using transientObjects of Inventor objects, colors can be created and assigned&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main()

    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim oTG As TransientObjects
    Set oTG = ThisApplication.TransientObjects

    Dim docAsset As Assets
    Set docAsset = oDoc.Assets

    Dim appearance As Asset
    Set appearance = docAsset.Item("Appearance Name")
    'appearance = docAsset.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", "appearances", "New Appearance")

    Dim generic_color As ColorAssetValue
    Set generic_color = appearance.Item("generic_diffuse")
    generic_color.Value = oTG.CreateColor(243, 35, 56)
    generic_color.HasConnectedTexture = True
End Sub&lt;/PRE&gt;
&lt;P&gt;Please feel free to contact if there is any doubt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If solves problem, click on "Accept as solution" / give a "Kudo".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 11:54:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304338#M98796</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2017-08-16T11:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Appearance Asset SetColor Method</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304921#M98797</link>
      <description>&lt;P&gt;Hi JaneFan, Chandra,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for both of the Light-Speed replies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried about a dozen different code fragments to change the base color using .SetColor.&amp;nbsp; It never occurred to me to&amp;nbsp;try the .CreateColor method on an existing Appearance to modify it.&amp;nbsp;&amp;nbsp;So...is the .SetColor method obsolete or is it just not&amp;nbsp;fully exposed to VBA?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The .CreateColor works great and&amp;nbsp;as only the one method is required, I think I can rewrite and simplify some of my code.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ron W.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 14:41:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7304921#M98797</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-16T14:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Appearance Asset SetColor Method</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7306721#M98798</link>
      <description>&lt;P&gt;Hello Ron,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Color.SetColor is not obsoleted, which is still valid and fully supported for a single Color object. But for ColorAssetValue.Value(Color Object) in AppearanceAsset case, it is not working in this way. We can prove in such way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim color As ColorAssetValue&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set color = appearance.Item("generic_diffuse")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim ogetC As color&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set ogetC = color.Value&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call oGetC.SetColor(0, 0, 255)&lt;/P&gt;
&lt;P&gt;With the upper code, we can see the object ogetC is changed by .SetColor(), while color.Value stays unchanged since it is considered as the different object from ogetC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the workaround working for you to Set color value in this case by ColorAssetValue.Value = (xxx, xxx, xxx)?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 03:03:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7306721#M98798</guid>
      <dc:creator>JaneFan</dc:creator>
      <dc:date>2017-08-17T03:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Appearance Asset SetColor Method</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7307817#M98799</link>
      <description>&lt;P&gt;Hi Jane,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the .CreateColor works fine for my use.&amp;nbsp; In desperation, I probably would have tried it at some point...it just hadn't occurred to me at the time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now see the&amp;nbsp;difference in the ColorAssetValue and the Color object.&amp;nbsp; Previously the distinction was unclear to&amp;nbsp;me.&amp;nbsp; If the object isn't dimensioned, .SetColor doesn't work.&amp;nbsp; It would be nice if it had returned some kind of 'debug' error or warning.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my use, I have a set of standard colors used for illustration purposes.&amp;nbsp; The colors are straight RGB colors, no textures, cutouts etc. but some have transparency and reflectivity properties.&amp;nbsp; Colors are applied to an occurrence&amp;nbsp;in an assembly&amp;nbsp;for use in an Iso drawing view usually.&amp;nbsp; Colors are used for clarity, there is no intent to render anything realistically and are created locally on the fly from a data value set, hard coded into my 'CangeColor' macro.&amp;nbsp; It lets me create constantly colored drawing views from any model for presentations and design reviews so a drawing printed for a design review is colored the same as the live model used in the presentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway I modified my routines an all is working well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ron Wollenschlager&lt;/P&gt;&lt;P&gt;BWXT Nuclear Energy Canada Inc.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:12:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/appearance-asset-setcolor-method/m-p/7307817#M98799</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-17T13:12:27Z</dc:date>
    </item>
  </channel>
</rss>

