ThreeDot Posted March 4, 2021 Share Posted March 4, 2021 Most photo and illustration software have a single keyboard shortcut to toggle guides on and off. Vectorworks has two separate menu items with two separate shortcuts. Is there a way to map guides on and off to a single keyboard shortcut? Thanks, Matthew Quote Link to comment
Christiaan Posted March 4, 2021 Share Posted March 4, 2021 (edited) Not that I know of but you can use a palette script. Create a new script in the Resource Browser and use this (altering 'Guides' if you use a different Class): IF ((GetCVis('Guides')) = 0) THEN BEGIN HideClass('Guides');END ELSE ShowClass('Guides');END; I call it Toggle Guides. Then you just keep that palette open and double click on the script when you want to toggle. Edited March 4, 2021 by Christiaan 3 Quote Link to comment
ThreeDot Posted March 4, 2021 Author Share Posted March 4, 2021 Thank you, Christiaan! I placed your script my custom "Plugins" menu and assigned a keyboard shortcut. I use the same shortcut (command + ; ) that I use in Illustrator. This is super helpful. 1 Quote Link to comment
Christiaan Posted March 4, 2021 Share Posted March 4, 2021 Ha, perfect! Didn't think of that. Quote Link to comment
Boh Posted March 4, 2021 Share Posted March 4, 2021 I like this script! Does anyone know of a script out that will toggle off the visibility of the guides class in all viewports? I know this can be done by editing the guides class but a toggle command would be really handy... 🙂 Quote Link to comment
Pat Stanford Posted March 4, 2021 Share Posted March 4, 2021 That script can be written, but it is probably closer to 30-50 lines of code rather than the 1 line in the general toggle. I will see if I can get to this over the weekend if no-one has done it by then. 1 Quote Link to comment
Boh Posted March 4, 2021 Share Posted March 4, 2021 Thankyou Pat. I was hoping one already existed as I didn't expect anyone to write one. If you have the time and don't mind it would be much appreciated! Quote Link to comment
Pat Stanford Posted March 6, 2021 Share Posted March 6, 2021 OK, here is a script to toggle the Guide Class in a selected Viewport. The Viewport must be the First Selected Object on the layer, so it is best to have only the viewport selected. If the Class defined in the Const section at the top of the script is Visible or Grey in the viewport it will be set to Invisible. If the Class is Invisible it will be set to Visible. Copy everything in the code block below and paste into a new blank Vectorscript, select the viewport, and run the script. Procedure ToggleGuidesInVP; {March 5, 2021} {©2021 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {No Warranty Expressed of Implied. Use at your own risk.} {Toggles the class defined in the Constant ToggleClass in a} {Viewport that is the First Selected object on the Active Layer.} Const ToggleClass='Guides'; Var H1: Handle; B1: Boolean; Class_Vis: Integer; Begin H1:=FSActLayer; If GetTypeN(H1)=122 then {Check that VP is selected} Begin B1:=GetVPClassVisibility(H1, ToggleClass, Class_Vis); If B1 then Case Class_Vis of 0: B1:=SetVPClassVisibility(H1, ToggleClass, -1); {Hide Class} -1: B1:=SetVPClassVisibility(H1, ToggleClass, 0); {Show Class} 2: B1:=SetVPClassVisibility(H1, ToggleClass, -1); {Hide Class if Grey} End; End; Redraw; End; Run(ToggleGuidesInVP); 2 Quote Link to comment
Pat Stanford Posted March 6, 2021 Share Posted March 6, 2021 So the next question is do you need a version that works on more than a single Viewport? If so what do you want it to do? The two biggest questions are: 1. All Viewports in the file or just viewports on the active layer? 2. What do you want to do when there are viewports that have different Class Visibilities for the target class? If you have one VP with the class. visible and one with it invisible what do you do? Set all of them to match the toggle of the first? Or toggle each one individually based on it's settings? 1 Quote Link to comment
Boh Posted March 6, 2021 Share Posted March 6, 2021 Wow! That is fantastic! And yes another script to toggle the guides class in all vps wld be perfect. To your questions: 13 hours ago, Pat Stanford said: 1. All Viewports in the file or just viewports on the active layer? All viewports (incl design layer vps if that is easy) 13 hours ago, Pat Stanford said: 2. What do you want to do when there are viewports that have different Class Visibilities for the target class? Toggle them all off. When run again the script can just toggle them all on. Thanks @Pat Stanford!! Quote Link to comment
Pat Stanford Posted March 13, 2021 Share Posted March 13, 2021 Sorry to take so long. It has been a busy week. Here is the script to toggle the visibility of the Guides class of all viewports. If the First Selected Object on the Active Layer is a viewport, the visibility of the Guides class will be toggled and then that visibility will be copied to all other viewports in the file. Very lightly tested. Use with Caution until you are certain it is suitable for your needs. Procedure ToggleGuidesInAllVPs; {March 13, 2021} {©2021 Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {No Warranty Expressed of Implied. Use at your own risk.} {Toggles the class defined in the Constant ToggleClass in the first selected} {Viewport that is the First Selected object on the Active Layer. Then copies that} {visibility to all other viewports in the file.} Const ToggleClass='Guides'; Var B1: Boolean; Class_Vis: Integer; H1: Handle; Procedure Execute(Hd1:Handle); Begin If GetTypeN(Hd1)=122 then {Check that VP is selected} Begin Case Class_Vis of 0: B1:=SetVPClassVisibility(Hd1, ToggleClass, -1); {Hide Class} -1: B1:=SetVPClassVisibility(Hd1, ToggleClass, 0); {Show Class} 2: B1:=SetVPClassVisibility(Hd1, ToggleClass, -1); {Hide Class if Grey} End; End; Redraw; End; Begin H1:=FSActLayer; If GetTypeN(H1)=122 then {Check that VP is selected} Begin B1:=GetVPClassVisibility(H1, ToggleClass, Class_Vis); If B1 then Case Class_Vis of 0: B1:=SetVPClassVisibility(H1, ToggleClass, -1); {Hide Class} -1: B1:=SetVPClassVisibility(H1, ToggleClass, 0); {Show Class} 2: B1:=SetVPClassVisibility(H1, ToggleClass, -1); {Hide Class if Grey} End; Redraw; ForEachObject(Execute, ((T=VIEWPORT))); End Else AlrtDialog('The First Selected Object Must be a Viewport.'); End; Run(ToggleGuidesInAllVPs); 1 Quote Link to comment
Boh Posted March 14, 2021 Share Posted March 14, 2021 (edited) Very cool @Pat Stanford! That has taken a lot of annoying repetitiveness out of our work. We have a drawn grid as part of our titleblocks and also on design layers that we use to set up our drawings. The grid is on the guides class so the ability to flick this class off and on quickly is a real asset. Thank you so much! I notice that by simply changing the class name in the first line of the script that this can be used to toggle on/off other classes too. That is also very handy! Edited March 14, 2021 by Boh Quote Link to comment
Pat Stanford Posted March 14, 2021 Share Posted March 14, 2021 Glad you like it. I usually try to make my scripts to be easily configurable if you need to do the same with with a different Layer/Class/Record/Field/Object Type/etc. And you can relatively easily convert these scripts to menu commands so you can add them to your workspace and give them keyboard shortcuts if desired. 1 Quote Link to comment
Boh Posted March 14, 2021 Share Posted March 14, 2021 21 minutes ago, Pat Stanford said: And you can relatively easily convert these scripts to menu commands so you can add them to your workspace and give them keyboard shortcuts if desired. Already done that! 🙂 Thanks again! 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.