<?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 edit background color with script in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597496#M91899</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You're missing the function that updates the DWG.&lt;/P&gt;&lt;PRE&gt;applicationcommand("updatedwglayerlist", background, shapeNode);&lt;/PRE&gt;&lt;P&gt;Here's an example script of it all working&lt;/P&gt;&lt;PRE&gt;Object background = Model.find("ModelBackground1");
treenode shapeNode = background.find("&amp;gt;visual/shape");
Color newColor = Color.blue;

for (int i = 1; i &amp;lt;= shapeNode.subnodes.length; i++) {
&amp;nbsp; &amp;nbsp; treenode colorNode = shapeNode.subnodes&lt;I&gt;.first;
    colorNode.value = 3;
&amp;nbsp; &amp;nbsp; colorNode.subnodes[1].value = newColor.r * 255;
&amp;nbsp; &amp;nbsp; colorNode.subnodes[2].value = newColor.g * 255;
&amp;nbsp; &amp;nbsp; colorNode.subnodes[3].value = newColor.b * 255;
}

applicationcommand("updatedwglayerlist", background, shapeNode);&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;Note, that while this script works now, it is relying on the current tree structure and there's no guarantee that this tree structure will remain the same going forward.&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 17 Jul 2023 15:32:25 GMT</pubDate>
    <dc:creator>Matthew_Gillespie</dc:creator>
    <dc:date>2023-07-17T15:32:25Z</dc:date>
    <item>
      <title>How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597495#M91898</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 23.0.9 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P id="isPasted"&gt;I wanted to edit the background color and ran the script below.&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P id="isPasted"&gt;/**Custom Code*/&lt;/P&gt;&lt;P&gt;Object current = param(1);&lt;/P&gt;&lt;P&gt;treenode activity = param(2);&lt;/P&gt;&lt;P&gt;Token token = param(3);&lt;/P&gt;&lt;P&gt;treenode processFlow = ownerobject(activity);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;for (int i = 1; i &amp;lt;= Model.find("ModelBackground1").find("&amp;gt;visual/shape").subnodes.length; i++) {&lt;!-- --&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="white-space: normal;"&gt;&lt;SPAN style="white-space:pre;"&gt;    &lt;/SPAN&gt;Model.find("ModelBackground1").find("&amp;gt;visual/shape").subnodes&lt;I&gt;.subnodes[1].subnodes[1].value = 0;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="white-space: normal;"&gt;&lt;SPAN style="white-space:pre;"&gt;    &lt;/SPAN&gt;Model.find("ModelBackground1").find("&amp;gt;visual/shape").subnodes&lt;I&gt;.subnodes[1].subnodes[2].value = 0;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="white-space: normal;"&gt;&lt;SPAN style="white-space:pre;"&gt;    &lt;/SPAN&gt;Model.find("ModelBackground1").find("&amp;gt;visual/shape").subnodes&lt;I&gt;.subnodes[1].subnodes[3].value = 0;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P id="isPasted"&gt;-----------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;The tree information and UI are changing correctly, but the actual background color remains the same. Am I missing some settings?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image001.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1518332i99F104B3CF3E6D17/image-size/large?v=v2&amp;amp;px=999" role="button" title="image001.png" alt="image001.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image002.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1518334iE552E5E4000B61C6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image002.png" alt="image002.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've confirmed that setting the color manually can change it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 17 Jul 2023 13:39:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597495#M91898</guid>
      <dc:creator>tsuji_ryusuke</dc:creator>
      <dc:date>2023-07-17T13:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597496#M91899</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You're missing the function that updates the DWG.&lt;/P&gt;&lt;PRE&gt;applicationcommand("updatedwglayerlist", background, shapeNode);&lt;/PRE&gt;&lt;P&gt;Here's an example script of it all working&lt;/P&gt;&lt;PRE&gt;Object background = Model.find("ModelBackground1");
treenode shapeNode = background.find("&amp;gt;visual/shape");
Color newColor = Color.blue;

for (int i = 1; i &amp;lt;= shapeNode.subnodes.length; i++) {
&amp;nbsp; &amp;nbsp; treenode colorNode = shapeNode.subnodes&lt;I&gt;.first;
    colorNode.value = 3;
&amp;nbsp; &amp;nbsp; colorNode.subnodes[1].value = newColor.r * 255;
&amp;nbsp; &amp;nbsp; colorNode.subnodes[2].value = newColor.g * 255;
&amp;nbsp; &amp;nbsp; colorNode.subnodes[3].value = newColor.b * 255;
}

applicationcommand("updatedwglayerlist", background, shapeNode);&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;Note, that while this script works now, it is relying on the current tree structure and there's no guarantee that this tree structure will remain the same going forward.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 17 Jul 2023 15:32:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597496#M91899</guid>
      <dc:creator>Matthew_Gillespie</dc:creator>
      <dc:date>2023-07-17T15:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597497#M91900</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/87/matthew.g.html" nodeid="87"&gt;@Matthew Gillespie&lt;/A&gt; ,&lt;/P&gt;&lt;P id="isPasted"&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;When I applied the sample code you advised to the attached dwg file, the color of "Equipment Layer" was changed, but the other colors were not changed.&lt;/P&gt;&lt;P&gt;Is there a way to change other items as well?&lt;/P&gt;&lt;P&gt;Or is there information about "updatedwglayerlist" documented somewhere?&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/71100-er-small.dwg" target="_blank"&gt;ER_small.dwg&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 Jul 2023 01:58:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597497#M91900</guid>
      <dc:creator>tsuji_ryusuke</dc:creator>
      <dc:date>2023-07-18T01:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597498#M91901</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hey &lt;A rel="user" href="https://answers.flexsim.com/users/28681/ryusuket.html" nodeid="28681"&gt;@Ryusuke T&lt;/A&gt;! I noticed when I ran it that only the equipment layer changed but if I changed all the layers to a different color and then ran the script it changed all of them... could be a bug. I'm going to try running it with a few more dwg files and see if the same thing happens.&lt;/P&gt;
 &lt;P&gt;Here is the coding reference to the command applicationcommand&lt;/P&gt;
 &lt;P&gt;&lt;A href="https://docs.flexsim.com/en/23.2/Reference/CodingInFlexSim/CommandReference/Commands.html#applicationcommand" target="test_blank"&gt;https://docs.flexsim.com/en/23.2/Reference/CodingInFlexSim/CommandReference/Commands.html#applicationcommand&lt;/A&gt; which is just acting on the tree node "updatedwglayerlist"&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 Jul 2023 16:04:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597498#M91901</guid>
      <dc:creator>julie_weller</dc:creator>
      <dc:date>2023-07-18T16:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597499#M91902</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Yeah no matter the dwg file I use, it updates the colors in the ModelBackground pop up but doesn't in the model, however if I change all the colors once and then run the script it works. Interestingly when I delete the background and add it again after doing all that, it is still able to be changed. 
 &lt;A rel="user" href="https://answers.flexsim.com/users/87/matthew.g.html" nodeid="87"&gt;@Matthew Gillespie&lt;/A&gt; Do you think this is a bug or is there just something that needs to be called first?
&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 Jul 2023 16:14:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597499#M91902</guid>
      <dc:creator>julie_weller</dc:creator>
      <dc:date>2023-07-18T16:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597500#M91903</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Sorry, I tested my script in a model where I'd already changed the colors manually so it seemed to all be working. It looks like that script needs to set the value of the colorNode itself too. I updated the script above with the extra line.&lt;/P&gt;&lt;P&gt;updatedwglayerlist is not documented because it's a function that was not designed as a public API. It's just some code that is called by the properties window. This is not a feature request that has come up before and so we haven't designed and exposed a public API.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 Jul 2023 16:21:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597500#M91903</guid>
      <dc:creator>Matthew_Gillespie</dc:creator>
      <dc:date>2023-07-18T16:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit background color with script</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597501#M91904</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P id="isPasted"&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/87/matthew.g.html" nodeid="87"&gt;@Matthew Gillespie&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;I have verified that all shapes are updated with the updated script code.&lt;/P&gt;&lt;P&gt;Thank you for your support.&lt;/P&gt;&lt;P&gt;I would like to use it recognizing that it is not permanently guaranteed.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Jul 2023 00:32:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-edit-background-color-with-script/m-p/13597501#M91904</guid>
      <dc:creator>tsuji_ryusuke</dc:creator>
      <dc:date>2023-07-19T00:32:49Z</dc:date>
    </item>
  </channel>
</rss>

