P Retondo Posted May 23, 2020 Share Posted May 23, 2020 Anyone have any quick guidance about how to change the 2d objects view preference in Unified View Options via a VS routine that can be invoked with a keyboard command? I wish there were a macro utility that could capture VW commands and automatically transform them into VS language the way Excel can with Visual Basic. Quote Link to comment
Pat Stanford Posted May 23, 2020 Share Posted May 23, 2020 What view preferences are you talking about? What are you trying to accomplish? Quote Link to comment
P Retondo Posted May 23, 2020 Author Share Posted May 23, 2020 View 2d objects. I need to turn those on and off all the time when working in 3d. Quote Link to comment
MullinRJ Posted May 24, 2020 Share Posted May 24, 2020 Hi Pete, I believe 95 is your number. That is the VW Preference number for the action you want. Here's a script that will toggle it. If this is not the action you desire, write back. Do you need help creating the Menu Command? I can post that, too, if it will help. { This script will toggle the Stack Layers (Unified View) option to display 2D objects } { and BEEP when the option is active (2D objects are visible). } { 24 May 2020 - Raymond J Mullin } SetPref(95, not GetPref(95)); if GetPref(95) then SysBeep; Raymond 1 Quote Link to comment
P Retondo Posted May 25, 2020 Author Share Posted May 25, 2020 Thanks, Ray! 95 it is. I used Plugin Manager to create a plug in, and added the command to my workspace. 10 seconds x 1000 saved! Quote Link to comment
MullinRJ Posted May 25, 2020 Share Posted May 25, 2020 (edited) Pete, Good it works. You must be using VW 2020. If you're planning to use it in VW 2017 you will need a slightly longer script. I wrote the above script in VW 2020, and it worked perfectly, but I tried it in VW 2017, and I have to also toggle the Unified View OFF and ON to make the screen redraw properly. You're on a PC, I'm on a Mac, so they may work differently, but if you don't get instant redraw then you can modify the script to the one shown below. The last two lines toggle Unified View twice to force the screen to redraw. This seems to be necessary in VW 2017, but not newer versions. The script above works as desired in VW 2018, VW 2019, and VW 2020. Here's a modified script that will work in VW 2017 (and newer). Neither version works in VW 2016. I have not tried it in versions earlier than VW 2016. { This script will toggle the Stack Layers (Unified View) option to display 2D objects } { and BEEP when the option is active (2D objects are visible). } { 24 May 2020 - Raymond J Mullin } SetPref(95, not GetPref(95)); if GetPref(95) then SysBeep; { Toggle Unified View to update screen redraw } SetPref(94, not GetPref(94)); SetPref(94, not GetPref(94)); Raymond Edited May 25, 2020 by MullinRJ Script does not work in VW 2016. Quote Link to comment
P Retondo Posted May 25, 2020 Author Share Posted May 25, 2020 The original two line script worked perfectly in VW2020. 1 Quote Link to comment
MullinRJ Posted May 25, 2020 Share Posted May 25, 2020 (edited) I modified my previous post. Neither version of the script works in VW 2016 as a menu command, but the longer version does work when run in a Script Palette. The longer script works in VW 2017 (and newer). The original script (shorter one) works in VW 2018 and newer. Raymond Edited May 25, 2020 by MullinRJ clarification of scope Quote Link to comment
P Retondo Posted May 25, 2020 Author Share Posted May 25, 2020 (edited) Ray, just for reference, here's the script for a toggle command I've been using for quite a while. I can't remember the name of the person who posted it, it works in the form of a .vsm as a plug-in: Procedure group; begin SetPref(14,not GetPref(14)); end; run(group); This script toggles "view other objects in group." Edited May 25, 2020 by P Retondo 1 Quote Link to comment
MullinRJ Posted May 25, 2020 Share Posted May 25, 2020 Hi Pete, Because a basic toggle script requires no variables, it can be reduced to one line SetPref(14, not GetPref(14)); but there is nothing wrong with placing that line inside a PROCEDURE definition and using a RUN() statement to execute it. You can use this, or my, format to create toggle scripts for any of the boolean VW Preferences. A list of preference numbers can be found online on the Developer Wiki in the Appendix. Here's a link: https://developer.vectorworks.net/index.php/VS:Function_Reference_Appendix#apppref This is not the complete list, but it's pretty inclusive. Just substitute a different number for the one in the script and save it to a new VSM command. I've got 14 of these loaded in my workspace and most have a HotKey for quick access, and the one you just posted is one of them. Building these is one of the quickest ways to make VW work as fast as you can think. They are real time savers. HTH, Raymond 1 Quote Link to comment
P Retondo Posted May 25, 2020 Author Share Posted May 25, 2020 Thanks Ray, you have been incredibly helpful! I just wonder if wrapping the SetPref function call in a procedure might be what earlier versions of VW require? (I guess I'm too lazy to check it out.) Quote Link to comment
Pat Stanford Posted May 25, 2020 Share Posted May 25, 2020 Nope. Unless you are using variables you have been able to use the unwrapped version since at least Minicad 5. 2 Quote Link to comment
JBenghiat Posted June 10, 2020 Share Posted June 10, 2020 On 5/23/2020 at 3:48 PM, P Retondo said: I wish there were a macro utility that could capture VW commands and automatically transform them into VS language the way Excel can with Visual Basic. Not quite as straightforwards, but you can export a script of your whole file: File:Export:Export Script. If you're trying to get started creating geometry, this is a great technique. In the case of a setting, you could export both options and compare the files. Not everything gets captured, though, so it wouldn't help you in this case. 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.