Jump to content
Developer Wiki and Function Reference Links ×

Set unified view pref


Recommended Posts

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.

Link to comment

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

  • Like 1
Link to comment

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 by MullinRJ
Script does not work in VW 2016.
Link to comment

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 by MullinRJ
clarification of scope
Link to comment

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 by P Retondo
  • Like 1
Link to comment

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

  • Like 1
Link to comment
  • 3 weeks later...
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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...