ScriptSpot

Forum topic · Scripts Wanted

help with script to save and restore views

By jsrocha · 2024-04-30

Description

Hi guys, how´s going?
i need a help with a script i have, wich i "wrote" using macro recorder (i´m not a coder). Basically the script has two buttons, one saves the current view and the other restores the saved view. The thing is that it does not recognize if the view is a perspective or orthographic, so sometimes it gives an error if the saved is not the same type as the actual view (example, when i try to restore a saved perspective in an ortho view).
So, is there a way to "typify" (i don´t know if this word exists) the saved view, so the script does the restoration correctly, without errors? can anyone help with that?
Below the script that i´m using:

(
-- Define the dialog with two buttons
rollout Bttn_view "Bttn_view" width:100 height:60
(
button button1 "Save-view"
button button2 "Restore-view"

-- Define button 1 click event handler
on button1 pressed do
(
actionMan.executeAction 0 "40227" -- Views: Save Active View
)

-- Define button 2 click event handler
on button2 pressed do
(
actionMan.executeAction 0 "40228" -- restore saved view
)
)

-- Create an instance of the dialog
createDialog Bttn_view
)

Thanks in advance,

Jsrocha

Comments (2)

jsrocha · 2024-05-02

Hi miauu,
actually i use the script you mentioned, but i need a more agile script. This one is good, i use it a lot, but for some tasks i need something faster.
Thanks for your suggestion ;-)
Cheers,

Jsrocha