I have two viewports. When I rotate / scale one, I would like the second one to update to the same view as well.
Is there any callback I can fork into when a viewport gets focus? (This would let me grab the view info from the other view and set in the newly activated view).
Alternatively if there is anything else to keep views in sync.
Try the attached plb, which has a PCL routine that will synchronise all other viewports to your current viewport.
Load the plb into Patran by typing the following on the Patran command line: !!lib ds_viewport_sync.plb
(You can load this automatically for every Patran session by putting the command in your p3epilog.pcl file - let me know if need more info on how to do that.)
To run the routine, type the following: ds_viewport_sync()
Of course you won't want to have to type that command every time you want to synchronise your views, and there are lots of options if you're prepared to do little customisation. Probably the easiest one is to assign the command to a hotkey. Add the following entry to your Patran.EventMaps file:
Shift<Key>v: CallPCL(ds_viewport_sync)
This will activate the command when you press Shift+v. You can change that to any other key you want. For more info on setting up hotkeys, see this article:
Another thing you can do is to add an item to the viewport right mouse button (RMB) menu:
The RMB menu can be customised using two user_defined files: p3_user_menu.xml and p3_user_menu_res.xml. You can create these in your home directory, and add the contents of the attached files to them. This should set up the menu as shown in the picture. You can find more info on RMB menu customisation in the Patran help:
Warning the following is not intended for normal use.
Depending on how much you really want to keep those view ports synchronized:
I noted that with a !!trace calls that the graphics manager is checking the display status of other viewing menu forms when you release the mouse after rotating a view. So, if you're prepared to sacrifice a complete menu class like "viewing, View From/To" - you could "hijack" it by redefining the class and use it to update the other displays.
So I wrote a uil_view_fromto.pcl class that uses Darrel's library, it basically does nothing except call Darrels function.
Compile it and add it in to the library, or just add another library with it in or compile it live in the session (!! input uil_view_fromto.pcl). This uil_view_fromto class of functions will be found before the standard ones (due to the searching order for finding functions) so that the standard functionality is no longer available, so that is a big reason not to do this but it depends on what you're prepared to sacrifice in order to get that synchronization automatic.
Thanks guys, the hijacking of view from/to works like a charm.
I didn't use the PLB since I need to integrate the PCL into our library (this is for CSRS application) and I already have a save / restore view functionality.