question

TOTH-EM avatar image
0 Likes"
TOTH-EM asked TOTH-EM edited

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

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,

FlexSim 17.1.2
copyingmodel findpasting
5 |100000

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

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered TOTH-EM commented

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].

· 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.

TOTH-EM avatar image TOTH-EM commented ·

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.

1 Like 1 ·
Steven Hamoen avatar image
1 Like"
Steven Hamoen answered TOTH-EM edited

@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.

· 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.

TOTH-EM avatar image TOTH-EM commented ·

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 0 ·
Steven Hamoen avatar image Steven Hamoen TOTH-EM commented ·

@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 0 ·
TOTH-EM avatar image TOTH-EM Steven Hamoen commented ·

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 0 ·
Show more comments