I need to create 100 "different" processors at the same time, how can I do this using the code?
I need to create 100 "different" processors at the same time, how can I do this using the code?
I suggest you try this in process flow, because you will probably set names and locations, too. You start with a scheduled source. Therein you assign a new label to the token to set the desired quantity. Then you insert a run sub process flow activity. The quantity of repeating comes from the previous set label. You assign to the children a label which contains the creationRank as value. This label can you use to set a number as a string in the name for the processor. The subflow starts with a start activity, then you put a create object activity, which creates the processor from the library in the model(). You assign the created object reference to a label at the token in the sub process. It is a child token. You need such a reference to set a name. Then you can insert a finish activity, because the processors have been created.
If you want to set names and locations, you inserts a source code activity for the naming and a change visual activity for the location in front of the finish activity
token.createdObjReference.name = “Processor”+string.fromNum(token.ID);// sets the name
ID is an example for a name, which contains the value from creationRank.
You should additionally append the reference of each created processor from the child token to the parent token, too. Later you are able to destroy the processors again with this data, otherwise each time you let run the model the same amount of processors are created additionally.
I hope, I was able to give you some hints. If you haven’t got any experiences with process flow, you should do some of the tutorials from the manual.
If you just want to duplicate a processor, you can copy your processor several times. There is also a tool named edit selected objects in view from main menu, which can duplicate all selected objects, change their names and copy parameters and function settings from an highlighted object to selected objects.
Hello, thanks for answering my question. I'm a rookie for FlexSim. I want to figure out that why I can't use this code to generate 100 processors at the same time without setting their location? Thanks!
for (int i = 1; i <= 100; i++) {
createinstance(node("/fixedresources/Processor", library()),model());
}
The code you wrote does create 100 processors, they just all have the same location:
17 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved