question

Rich G6 avatar image
0 Likes"
Rich G6 asked Ryan Clark commented

Can I set the rank of an object by importing a excel spreadsheet?

If I have a simple model that contains a Source1 (Rank 3), Queue1 (Rank 4), Processor1 (Rank 5) and a Sink1 (Rank 6), how can I change the rank of the objects in my model using an excel spreadsheet?

For example, using an excel spreadsheet that contains 2 columns (1 for the Name of objects, 1 for the Rank of objects) and 5 rows (1 for the heading, 4 for the number of objects in the model). Using the User Commands custom code option, what code can I create so that I can import an excel spreadsheet to change the rank of the objects?

Original ranks ----> New ranks

Source1 3 ---> 6

Queue1 4 ---> 5

Processor1 5 ---> 4

Sink1 6 ---> 3

FlexSim 21.1.5
name and rank
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Felix Möhlmann edited

You can use the "Post Import Code" option to adjust the ranks of the objects based on the imported table. The attached file assumes the table in the excel file has the following format:

1637226515930.png

This gets imported to a global table called "TreeRanks". The post import code sorts this table by rank and sets the ranks of the objects accordingly.

1637226735796.png

ChangeRanksWithImport.fsm


· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Rich G6 avatar image Rich G6 commented ·
Thank you Felix for you response. I was able to follow your instructions. However, once I imported my excel file into a global table, the object's rank in the model remained unchanged.


I placed a check mark on both "Import table on Model Reset" and "Execute Post Import Code" clicked on the "Post Import Code" and clicked on "Apply" and "OK" on that as well. How can I ensure the rank of each object is updated based on the excel file? Thanks again.

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Rich G6 commented ·
Have you checked if you copied the import code from my model correctly (maybe your table has a different name)? Do you get any error messages?

It'd be easier to help if you could upload your model or post screenshots of the relevant sections (import code, import window, table, tree).

1 Like 1 ·
Rich G6 avatar image Rich G6 Felix Möhlmann commented ·

I was unable to open your model because you are using a newer version of FlexSim. I am missing the code. Can you please paste the code in the comments? Thank you in advance. If that doesn't work, I will definitely upload my model file next.

0 Likes 0 ·
Show more comments
Rich G6 avatar image
0 Likes"
Rich G6 answered Ryan Clark commented

Thank you Felix! Your code worked perfectly. I really appreciate your help.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ryan Clark avatar image Ryan Clark commented ·

Hi @Rich G6,

I'm glad that @Felix Möhlmann was able to help you resolve your issue!

In the future, when you reply to answers to your questions, please don't post those comments as additional answers. Instead, you can click "Comment" or "Reply" to respond in a thread rather than adding a new answer each time.screenshot-2021-11-03-171101-li-2.jpg

The same thing applies when adding clarifications to your question. In that case, use the "Comment" button directly below the bottom of your original post.screenshot-2021-11-03-171244-li.jpg

Following these procedures helps to keep the post organized. For more information, please see Best practices for using this Answers site - FlexSim Community.

Thanks!

0 Likes 0 ·