<?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 create objects through FlexScript and then assign them to a group? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525444#M35439</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/19815/nathans6.html" nodeid="19815"&gt;@Nathan S6&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Here's a bit of code that will do what you're looking for:&lt;/P&gt;&lt;PRE&gt;for (int i = 1; i &amp;lt; 20; i++)	{
	Object newProcessor = createinstance(library().find("?Processor"), model());
	newProcessor.location.x = i;
	Group("Group1").addMember(newProcessor);
}
&lt;/PRE&gt;&lt;P&gt;You didn't provide a model, so I am attaching an example with the code in the script box. You can run it and see that it works, then customize it to your needs.&lt;/P&gt;&lt;P&gt;&lt;A id="25164" href="https://answers.flexsim.com/storage/attachments/25164-new-objects-add-to-group.fsm"&gt;new-objects-add-to-group.fsm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2020 18:40:29 GMT</pubDate>
    <dc:creator>tanner_p</dc:creator>
    <dc:date>2020-01-23T18:40:29Z</dc:date>
    <item>
      <title>How to create objects through FlexScript and then assign them to a group?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525443#M35438</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 20.0.2 ]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;I have a global table that contains a series of pieces of equipment, quantity, and x/y positions. The desire is to simply run a snippet of custom code at the beginning of the process flow that will then iterate through each resource, and then create an object in the model to represent the equipment, while also adding them to their associated group. I have been attempting to use the drawobject function to no avail. &lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Below is my code block so far:&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;for (int i = 1; i &amp;lt;= totalEquipment; i++){&lt;!-- --&gt;&lt;BR /&gt; int j = 0;&lt;BR /&gt; int numResource = Table("Equipment")&lt;I&gt;["Quantity"];&lt;BR /&gt; int xPos = Table("Equipment")&lt;I&gt;["xPos"];&lt;BR /&gt; int yPos = Table("Equipment")&lt;I&gt;["yPos"];&lt;BR /&gt; while (j &amp;lt; numResource){&lt;!-- --&gt;&lt;BR /&gt; //CREATE OBJECT HERE&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;//ASSIGN OBJECT TO GROUP&lt;BR /&gt; } &lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 18:21:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525443#M35438</guid>
      <dc:creator>nathan_s6</dc:creator>
      <dc:date>2020-01-23T18:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create objects through FlexScript and then assign them to a group?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525444#M35439</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/19815/nathans6.html" nodeid="19815"&gt;@Nathan S6&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Here's a bit of code that will do what you're looking for:&lt;/P&gt;&lt;PRE&gt;for (int i = 1; i &amp;lt; 20; i++)	{
	Object newProcessor = createinstance(library().find("?Processor"), model());
	newProcessor.location.x = i;
	Group("Group1").addMember(newProcessor);
}
&lt;/PRE&gt;&lt;P&gt;You didn't provide a model, so I am attaching an example with the code in the script box. You can run it and see that it works, then customize it to your needs.&lt;/P&gt;&lt;P&gt;&lt;A id="25164" href="https://answers.flexsim.com/storage/attachments/25164-new-objects-add-to-group.fsm"&gt;new-objects-add-to-group.fsm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2020 18:40:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525444#M35439</guid>
      <dc:creator>tanner_p</dc:creator>
      <dc:date>2020-01-23T18:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create objects through FlexScript and then assign them to a group?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525445#M35440</link>
      <description>&lt;PRE&gt;Table table = Table("Equipment");
Group group = Group("Equipment");
int totalEquipment = table.numRows;

for (int i = 1; i &amp;lt;= totalEquipment; i++) {		
	int numResource = &lt;I&gt;["Quantity"];
	double xPos = table&lt;I&gt;["xPos"];
	double yPos = table&lt;I&gt;["yPos"];
	for (int j = 1; j &amp;lt;= numResource; j++) {
		//CREATE OBJECT HERE
		Object newObject = createinstance(library().find("?Processor"), model());
		newObject.setLocation(Vec3(xPos, yPos, 0), Vec3(0.5, 0.5, 0));

		//ASSIGN OBJECT TO GROUP
		group.addMember(newObject);
	}
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jan 2020 18:43:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-objects-through-flexscript-and-then-assign-them-to/m-p/13525445#M35440</guid>
      <dc:creator>Matthew_Gillespie</dc:creator>
      <dc:date>2020-01-23T18:43:58Z</dc:date>
    </item>
  </channel>
</rss>

