question

Steven Chen avatar image
0 Likes"
Steven Chen asked Matthew Gillespie answered

Follow object and rotate view by using script

Hello,

I want to have camera follow a specific item on using video recorder. Since item doesn't exists before start model. I can't do this from context menu. So plan is writing a script in trigger to follow the item.

Another question is it possible to rotate view with given speed and degree when following an object?

FlexSim 19.2.4
video recorderfollow objectsviewpoint
5 |100000

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

Brandon Peterson avatar image
1 Like"
Brandon Peterson answered Brandon Peterson commented

Steven,

During your model run you can use a trigger to set the node ">viewsettings/followobject" on the view to the object you want to follow. For example, you could set the node to the 100th item to enter a processor. The view would then follow the item through the model. If you use the OnDraw trigger of an object to do this then you will have a pointer to the view by default so you wont have to make adjustments every time you close an open views. The down side is that it will do it for all the 3D views that are open.

There is not a direct way to rotate the view with a given speed and degree when following an object that I know of. There are a few pointers I can offer for doing it yourself. First, do it in a PreDraw trigger or the view will not rotate smoothly. Second, you'll want to uncheck the "Rotate with Object" option if you are using the default follow object in the view.

I hope this helps, Brandon

· 3
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

@steven.chen, @Brandon Peterson, If you add an object on top of the item you follow through your model and you let this object rotate by a kinematic. Then I would follow the object on Top and not the item to get the desired rotation.

1 Like 1 ·
Brandon Peterson avatar image Brandon Peterson ♦ Joerg Vogel commented ·

@Jörg Vogel That's a slick idea, Thanks!

1 Like 1 ·
Brandon Peterson avatar image Brandon Peterson ♦ commented ·

Steven,

I didn't include this model with the original post because I had to get some help updating it from version 4.3.2! There is an object in the model called "ViewControl" that has some code in the "OnPreDraw" trigger that may be helpful for you. Basically, this model was a manual way of doing what the follow object option does for you now. Because it was built in such an old version the code may be a little out of date but it still works.

Good Luck, Brandon

view-follow-v19-2-4-mv-1.fsm

0 Likes 0 ·
Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered
5 |100000

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

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.