question

Sung Kim avatar image
2 Likes"
Sung Kim asked Matthew Gillespie commented

How to set conveyor width using code?

I would like to read conveyor configuration from a global table and set it in a script. I used

setnodenum(node(">variables/localType/width", theConv), convWidth);

That command sets the value in the tree, but the visual does not change. I believe there is something I missed to refresh or update(?)

FlexSim 16.2.0
conveyorautobuildconveyor width
5 |100000

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

1 Answer

·
Matthew Gillespie avatar image
3 Likes"
Matthew Gillespie answered Matthew Gillespie commented

The conveyor's mesh (how it's drawn) only updates when it's told to. You can tell it to update by calling this function:

function_s(theConv, "makeMeshDirty");
· 9
5 |100000

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

Sung Kim avatar image Sung Kim commented ·

Hi, @Matthew Gillespie,

Much thanks for the answer!!. I attached the code you suggested immediately after my code, but not works for me... Still the node values are updated, but visual appearance not... any further suggestion?

Just FYI, I use 2016 update 2..

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Sung Kim commented ·

Oh, I assumed since you were changing the width of the local type that your conveyor is a custom type. If it's not a custom type, you either need to change it to be a custom type, or you need to change the width on the global conveyor type that you're applying to that conveyor. If you do the second option you'd be changing the width of every conveyor of that type in your model and would need to call the makeMeshDirty function on each one to see them update.

3 Likes 3 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Sung Kim commented ·

I'm also using 16.2 and it's working fine for me. Take a look at this model. Execute the code in the script window by clicking the green play button to see the width of the conveyor change.

0 Likes 0 ·
conveyorwidth.fsm (14.9 KiB)
Sung Kim avatar image Sung Kim commented ·

Ah ha!!

Yes, you are right. After I changed the conveyor type to Custom, it works!!! Thanks!!

Follow-up question, though.. can you teach me the command to change the conveyor type in code? I don't think just setnodestr()... Very much appreciate if you help me to change the type using a code also.

Thanks!

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Sung Kim commented ·

In this answer I explain how to change the type of a photo eye through code, it's basically the same for any conveyor object.

2 Likes 2 ·
Sung Kim avatar image Sung Kim Matthew Gillespie ♦♦ commented ·

THANKS!!

Thanks to your other post, changing conveyor type is also resolved!! Sweet!!

Thank you again for your help!

0 Likes 0 ·
Show more comments
Sung Kim avatar image Sung Kim commented ·

Hi, Matthew,

Yes, your model works on my machine too. When I do it in the new fresh model, the code works. I guess the previous model I tested seems to have corrupted or something.

THANKS MUCH!! again for your all help!!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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