<?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: Define process time using Code Snippet in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598342#M92589</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;how do I have to add it to the code in order to have a&lt;SPAN id="isPasted" style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt; normal(10,1)&lt;/SPAN&gt; process time?&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 09 Jan 2024 11:51:30 GMT</pubDate>
    <dc:creator>jonperez</dc:creator>
    <dc:date>2024-01-09T11:51:30Z</dc:date>
    <item>
      <title>Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598340#M92587</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 23.2.1 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello, I would like to know if there is any way to define the process time of a combiner by using Code Snippet. I attach a picture of the code where I want to define the process time with normal distribution.&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/77734-code-snippet.png" target="_blank"&gt;Code Snippet.png&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 11:27:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598340#M92587</guid>
      <dc:creator>jonperez</dc:creator>
      <dc:date>2024-01-09T11:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598341#M92588</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hi, you can set value of properties with the method setProperty, for example:&lt;/P&gt;&lt;PRE&gt;Object combiner = Model.find("Combiner1");
double newValue = 50;
combiner.as(Object).setProperty("ProcessTime", newValue);&lt;/PRE&gt;&lt;P&gt;If the owner of the code snippet is the combiner, you have the reference as current:&lt;/P&gt;&lt;PRE&gt;Object combiner = current;&lt;/PRE&gt;&lt;P id="isPasted"&gt;Depending on the case, it might be sufficient for the processing time to depend on that information, so you could use a custom code in the 'Process Time' cell. In this code, you should return the value according to the conditions you desire.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1704801188752.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1521809i19A759FF08557A06/image-size/large?v=v2&amp;amp;px=999" role="button" title="1704801188752.png" alt="1704801188752.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 11:46:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598341#M92588</guid>
      <dc:creator>iago_mf</dc:creator>
      <dc:date>2024-01-09T11:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598342#M92589</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;how do I have to add it to the code in order to have a&lt;SPAN id="isPasted" style="color: rgb(65, 65, 65); font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt; normal(10,1)&lt;/SPAN&gt; process time?&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 11:51:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598342#M92589</guid>
      <dc:creator>jonperez</dc:creator>
      <dc:date>2024-01-09T11:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598343#M92590</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You just have to write the reference to that distribution in FlexSim with the correct parameters, for example:&lt;/P&gt;&lt;PRE&gt;Object combiner = Model.find("Combiner1");
double newValue = normal(10,1);
combiner.as(Object).setProperty("ProcessTime", newValue);&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 11:55:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598343#M92590</guid>
      <dc:creator>iago_mf</dc:creator>
      <dc:date>2024-01-09T11:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598344#M92591</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;The process time value can be: a numeric single value; a string expression that is evaluated to lookup or generate a number, or multi-line code that does the same (also string).&lt;/P&gt;&lt;P&gt;When you say you want to "define the process time by code" it can mean two things - you can:&lt;/P&gt;&lt;P&gt;1) have that code as the process time expression/script to fire for each item&lt;/P&gt;&lt;P&gt;2) write the value/expression/script into the process time property using code (triggered elsewhere)&lt;/P&gt;&lt;P&gt;Of course you could be doing both of those things - trigger a script that writes an expression or script to the process time property (last example below).&lt;/P&gt;&lt;P&gt;Examples:&lt;/P&gt;&lt;PRE&gt;combiner.setProperty("ProcessTime", normal(10,1)); //writes a random value once &amp;nbsp;to the combiner - eg. 10.5 will be used until you set another value.&lt;/PRE&gt;&lt;PRE&gt;combiner.setProperty("ProcessTime", "normal(10,1,getstream(ownerobject(c)))"); // writes the single line &amp;nbsp;expression to be evaluated each time a process time is needed. &amp;nbsp;(notice no semicolon at the end of the expression)&lt;/PRE&gt;&lt;P&gt;Lastly the code to write the script will look like this where the lines are seperated by semicolons and crucially the process time is &lt;EM&gt;returned &lt;/EM&gt; by the script we supplied.&lt;/P&gt;&lt;PRE&gt;string newValue = "Object current=ownerobject(c); \
&amp;nbsp; &amp;nbsp;double sampletime=normal(10,1,getstream(current)); \
&amp;nbsp; &amp;nbsp;return sampletime;";
combiner.setProperty("ProcessTime", newValue); &lt;/PRE&gt;&lt;P&gt;Note the last two examples generate the same random samples.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 13:40:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598344#M92591</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2024-01-09T13:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598345#M92592</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you! Can I add here on code snippet?&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/77736-screenshot-flexsim.png" target="_blank"&gt;Screenshot flexsim.png&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 15:35:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598345#M92592</guid>
      <dc:creator>jonperez</dc:creator>
      <dc:date>2024-01-09T15:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598346#M92593</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Do you want to write the value dynamically in code or do you just want it as a fixed expression (in which case you can type directly into the process time field the normal expression)?&lt;/P&gt;&lt;P&gt;If you want to write it dynamically then when do you want that to happen?  An exit trigger will be too late for the current item for example.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jan 2024 16:23:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598346#M92593</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2024-01-09T16:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598347#M92594</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello Jason, I want that depending of the counter to have a different process time. For example, if the counter is 10 or less, to have a normal(10,1) process time and if the counter is between 10 and 20, to have a normal(15,2) process time. Is there any way to achieve in by writing it on the oxit or entry trigger of the combiner with the code snippet?&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;How would I need to add that on the code of this screenshot? And if it cannot be done, how would I need to do it?&lt;/P&gt;
 &lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/77753-code-snippet.png" target="_blank"&gt;Code Snippet.png&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Jan 2024 07:45:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598347#M92594</guid>
      <dc:creator>jonperez</dc:creator>
      <dc:date>2024-01-10T07:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598348#M92595</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;If the distribution and its parameters are dependent on values that are known/accessible when the process time is determined, you can write custom code in the Process Time field that does this. There is no need to set the process time from elsewhere.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/77766-process-time-fm.fsm" target="_blank"&gt;process-time-fm.fsm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And even if the values are not known at that time, I would still recommend to write code that uses (for example) a label on the combiner to determine the process time and only change that label externally, not the entire code.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:59:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598348#M92595</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2024-01-10T09:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Define process time using Code Snippet</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598349#M92596</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/43543/jonperez.html" nodeid="43543"&gt;@Jon Perez&lt;/A&gt;, was one of Jason Lightfoot's or Iago MF's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.&lt;/P&gt;&lt;P&gt;If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 17 Jan 2024 16:34:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/define-process-time-using-code-snippet/m-p/13598349#M92596</guid>
      <dc:creator>Jeanette_Fullmer</dc:creator>
      <dc:date>2024-01-17T16:34:05Z</dc:date>
    </item>
  </channel>
</rss>

