Jump to content
P Retondo

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.

Share this post


Link to post

What view preferences are you talking about?

 

What are you trying to accomplish?

Share this post


Link to post

View 2d objects.  I need to turn those on and off all the time when working in 3d.

Share this post


Link to post

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

Share this post


Link to post

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!

Share this post


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

Share this post


Link to post
Posted (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 by MullinRJ
clarification of scope

Share this post


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

Share this post


Link to post

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

Share this post


Link to post

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.)

Share this post


Link to post

Nope. Unless you are using variables you have been able to use the unwrapped version since at least Minicad 5.

  • Like 2

Share this post


Link to post
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.

Share this post


Link to post

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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...