Jump to content

Toggle Guides On/Off


Recommended Posts

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 by Christiaan
  • Like 3
Link to comment

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

 

 

Link to comment

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

 

  • Love 2
Link to comment

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?

  • Like 1
Link to comment

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!!

Link to comment

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

 

  • Love 1
Link to comment

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 by Boh
Link to comment

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.

  • Like 1
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...