MTRobin Posted May 22, 2020 Share Posted May 22, 2020 Hi Everyone, I am trying to write a VS to redefine the currently selected saved view. This way I can create a tool and assign it a shortcut key command. Then I can execute the saved view, edit it, then trigger my VS via shortcut keys and it will update the view. Does anyone have a good solution to this? As far as I can see there is no menu option for this so I think the only way is to create a VS to get the current view and redefine it. Any suggestions? Thank you, Maxwell Quote Link to comment
JBenghiat Posted May 22, 2020 Share Posted May 22, 2020 (edited) Take a look at my Snapback commands. https://benghiatlighting.com/software/downloads#Snapback This may do what you want — if not the code is open to adapt and edit. Edited May 22, 2020 by JBenghiat Quote Link to comment
MTRobin Posted May 22, 2020 Author Share Posted May 22, 2020 Thank you for this. Do you know how I can get the name of the currently selected saved view? Quote Link to comment
Pat Stanford Posted May 22, 2020 Share Posted May 22, 2020 I don't believe there is any way to get the name of the last run Saved View. Saved Views are not a state the program is in. They are only a script that runs and changes the state of the drawing. Once they run there is no connection between the current drawing state and the saved view. VW does not know if you have changed a view or a visibility after you executed a Saved View. 1 Quote Link to comment
MTRobin Posted May 22, 2020 Author Share Posted May 22, 2020 I see. I think what I might do is run a script in each saved view that sets a variable with its name. Since I don't typically make new saved views, instead I have a bunch that I predefined in my template file, I can just have the script run when I select a view. Then if I change it I can run my script and it will know the name based on the variable change. Now that I am typing this out is there a way to set a system wide variable that any script can grab? Also, when I use the VSave function can I specify Restore Options? As it is now it saves everything regardless of what the saved view I am overwriting had. Thanks, Maxwell Quote Link to comment
JBenghiat Posted May 22, 2020 Share Posted May 22, 2020 Look at https://developer.vectorworks.net/index.php/VS:Rpstr_SetValueStr for storing persistent values. You need to use object variables to set the particulars of the saved view (you save the view first, and then select the options that you do not want restored). I believe you can get a handle for the saved view with GetObject() and the view name. Here are the object variable constants for saved views: ovSheetSaveView = 450; // Boolean, true if the sheet saves the view orientation factors, which includes the orientation and projection - Public for VS ovSheetSavePage = 451; // Boolean, true if the sheet saves the page location - Public for VS ovSheetSaveClass = 452; // Boolean, true if the sheet saves the class options, active class and class visibilities - Public for VS ovSheetSaveLayer = 453; // Boolean, true if the sheet saves the layer options, active layer and layer visibilities - Not for public use ovSheetSaveZoomPan = 456; // Boolean, true if the sheet saves the zoom and pan settings - Public for VS ovSheetSaveStackLayers = 457; // Boolean, true if the sheet saves the stack layers settings - Not for public use ovSheetStackLayersStatus = 458; // Boolean, true if the sheet has layer stacking on - Not for public use ovSheetSaveActiveLayer = 459; // Sint32, read-only, the active layer internalIndex of the saved view ovSheetSaveActiveClass = 460; // Sint32, read-only, the active class internalIndex of the saved view ovSheetProjection = 461; // Sint16, read-only, the saved projectsion when ovSheetSaveView is on ovSheetSaveLayerOptions = 462; // Sint16, read-only, bit flag values for layer and class options: ovSheetSaveClassOptions = 463; // Sint16, read-only, 0x01 - showOther // 0x02 - grayOther // 0x04 - snapOnly // 0x08 - doSingle // // if ( NOT showOther ) THEN (1) "Active Only" // else if ( grayOther && snapOnly) THEN (3) "Gray/Snap Others" // else if ( grayOther ) THEN (2) "Gray Others"; // else if ( snapOnly) THEN (5) "Show/Snap Others"; // else if ( doSingle) THEN (4) "Show Others"; // else (6) "Show/Snap/Modify Others"; // // 1 - Active Only // 2 - Gray Others // 3 - Gray/Snap Others // 4 - Show Others // 5 - Show/Snap Others // 6 - Show/Snap/Modify Others Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.