Model().find("ObjName") fails after copy/pasting (Name change)

Model().find("ObjName") fails after copy/pasting (Name change)

touijer_o
Not applicable
20 Views
7 Replies
Message 1 of 8

Model().find("ObjName") fails after copy/pasting (Name change)

touijer_o
Not applicable

[ FlexSim 17.1.2 ]

Hi,

I have constructed two models and I want to copy paste one into the other.

Upon paste, the objects take different names. The name change however do not change in the internal triggers of each object. Particulary, a message sent to a processor (identified by :

model().find("Processor1")

will still be sent to the "Processor1" on the model, and not the renamed object. Which either fails or send it to the wrong object.

Chaging them manually takes a lot of time depending on the models size, Is there a way to make this process automatic? Should I use an alternative to model().find("ObjName")? If yes, what's the alternative I should use?

Thanks in advance,

0 Likes
Accepted solutions (1)
21 Views
7 Replies
Replies (7)
Message 2 of 8

SCHamoen
Advisor
Advisor

@TOTH-EM a solution that might working is the following. In 1 model you move everything into a visual tool, check if everything still works and then save the visual tool of in a user library. In the other model open the user library and drag in your visual tool. The names should be the same then, only the visual tool names should change.
Other option would be to save the visual tool of as .t file and load that in the model but that requires going to the tree.

Message 3 of 8

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

Instead of using the path or name of the object you could use connections to link objects and then reference those connections. For example, you could connect your object to Processor1 with a center port connection and then in your trigger refer to it as current.centerObjects[1].



Matthew Gillespie
FlexSim Software Developer

Message 4 of 8

touijer_o
Not applicable

That would indeed work, but this implies I'll have to add a connexion each time I need to call an object. Since I have some "for loops", I'm afraid that might take a long time.

Thanks for pointing it out though, I will probabely go for it if I can't get steve's solution to work.

Message 5 of 8

touijer_o
Not applicable

Thanks, after a quick look to the user manual, it seems that it's exactly what I needed.

I'll try it and accept the reply as soon as I get it to function.

EDIT: A question however, @steven.hamoen , do you know if the process flows/global tables/... will be transfered too?

EDIT2: Also, will pasting two times the same "model" create a problem?

0 Likes
Message 6 of 8

SCHamoen
Advisor
Advisor

@TOTH-EM you can put everything in the user library (tables, process flows etc) so you can easily drag them in if needed.

pasting two times in this case just means dragging in 2 times and that should be no problem.

0 Likes
Message 7 of 8

touijer_o
Not applicable

There's a catch however, I still need to change all the model().find(). As now, accessing the processor1 for example require me to write, for example "Plane1/Processor1". And the plane name differ after each drag an drop. (In fact, after trying, I noticed it will look for the first's plane/visual tool object for all the visual tools).

I'm also afraid it happens for process flows too.

0 Likes
Message 8 of 8

touijer_o
Not applicable

I wasn't clear. I'll try to formulate my comment and use an example.

Please consider the follwing basic example: simple-example.fsm

The processor 1 labels the items with the content of the Queue3. When I drag another visual item, the processor1 of the new visual item will still label them with the content of the Queue3 of the first visual tool, not the second.

You can verify it by breaking the link between source 1 and queue1.

The reason is because the model().find() is looking for the Plane1/Queue3 and not the new Queue3 (of the new plane).

0 Likes