Jump to content
  • 0

Turn Layer & Class On/Off All Viewports


Jim Smith

Question

Maybe there's a way to do this, but from time to time I need a new Layer or Class & either forget to make it visible to all at the time of creation, or a situation changes & want to show this Layer or Class on all (or mostly all) Viewports. 

 

Alternatively  I'd like to be able to select several  Viewports & turn on a Layer of Class. 

Link to comment

9 answers to this question

Recommended Posts

  • 0
1 hour ago, Jonathan Pickup said:

Of course, you need to have named your viewports correctly. 


Naming viewports is also essential for linking viewports. There is an amazing script that renames viewports: sht no./dwg no./dwg title. Saves SO much time. Can dig it out on Monday if you want it. 

  • Like 2
Link to comment
  • 0
On 10/19/2019 at 11:49 AM, Boh said:

Naming viewports is also essential for linking viewports. There is an amazing script that renames viewports: sht no./dwg no./dwg title. Saves SO much time. Can dig it out on Monday if you want it. 

There are two scripts below - I use these all the time. Credit to @michaelk.

 

Rename selected viewport: 

{This script will take all selected viewports and change the name of those viewports to be

        (Sheet Layer) (Drawing Number) (Drawing Name)

Procedure ViewportRename;

{Badly Scripted by Michael Klaers.  Updated Aug 2, 2015}

{This script will take all selected viewports and change the name of those viewports to be

		(Sheet Layer) (Drawing Number) (Drawing Name)

This version tries to force the name to appear immeidately in the name field, data tab, OIP when only one VP is selected.

Prior to this version the new name appeared immediately in the Nav Palette, but not in the name field.}


	Var
	VPDwgTitle,VPName,BText,VPNum : String;	
	h,hh:  Handle;
	ViewportLayer: Handle;
	ViewportLayerString: String;

	
	


	Procedure RenameVP(h : HANDLE);
Begin							{***********  BEGIN Procedure  ***********}	
	ViewportLayer:= GetLayer(h);
	ViewportLayerString:= GetLName(ViewportLayer);
	VPDwgTitle := GetObjectVariableString(h, 1032);
	VPNum := GetObjectVariableString(h, 1033);
	ResetObject(h);


{	Message('Viewport Handle: ',h,chr(13), 
			'Layer Handle: ',ViewportLayer,chr(13),
			'Layer Name: ',ViewportLayerString,chr(13),
			'VP Num: ',VPNum,chr(13),
			'VP Name: ',VPDwgTitle);
}

	SetName(h, Date(2,2));
	SetName(h, CONCAT(ViewportLayerString,' ',VPNum,' ',VPDwgTitle));

	SetDSelect(h);		{These two commands are just here to force the new name to appear in the }
	SetSelect(h);		{name field immediately.  They can be deleted w/o consequence}

End;							{***********  END Procedure  ***********}



Begin							{***********  Main Program  ***********}	

	ForEachObject(RenameVP,(((T=VIEWPORT) & (SEL=TRUE))));

End;

Run(ViewportRename);




Rename all viewports. 

{This script will take all selected viewports and change the name of those viewports to be

        (Sheet Layer) (Drawing Number) (Drawing Name)

Procedure ViewportRename;

{Badly Scripted by Michael Klaers.  Updated Aug 2, 2015}

{This script will take all selected viewports and change the name of those viewports to be

		(Sheet Layer) (Drawing Number) (Drawing Name)

This version tries to force the name to appear immeidately in the name field, data tab, OIP when only one VP is selected.

Prior to this version the new name appeared immediately in the Nav Palette, but not in the name field.}


{Forked version.  Sept 10 2018

This version will rename all viewports in the drawing regardless of what is currently selected.}

	Var
	VPDwgTitle,VPName,BText,VPNum : String;	
	h,hh:  Handle;
	ViewportLayer: Handle;
	ViewportLayerString: String;

	
	


	Procedure RenameVP(h : HANDLE);
Begin							{***********  BEGIN Procedure  ***********}	
	ViewportLayer:= GetLayer(h);
	ViewportLayerString:= GetLName(ViewportLayer);
	VPDwgTitle := GetObjectVariableString(h, 1032);
	VPNum := GetObjectVariableString(h, 1033);
	ResetObject(h);


{	Message('Viewport Handle: ',h,chr(13), 
			'Layer Handle: ',ViewportLayer,chr(13),
			'Layer Name: ',ViewportLayerString,chr(13),
			'VP Num: ',VPNum,chr(13),
			'VP Name: ',VPDwgTitle);
}

	SetName(h, Date(2,2));
	SetName(h, CONCAT(ViewportLayerString,' ',VPNum,' ',VPDwgTitle));

	SetDSelect(h);		{These two commands are just here to force the new name to appear in the }
	SetSelect(h);		{name field immediately.  They can be deleted w/o consequence}

End;							{***********  END Procedure  ***********}



Begin							{***********  Main Program  ***********}	

	ForEachObject(RenameVP,((T=VIEWPORT)  ));

End;

Run(ViewportRename);




 

  • Like 1
Link to comment
  • 0
17 hours ago, Boh said:

There are two scripts below - I use these all the time. Credit to @michaelk.

 

 

Hi Boh!  Glad you like them.  I use these scripts every day, also 😁.

 

I'm not terribly good at writing scripts - this one is just simple enough that I could handle it.  

 

But I have to extend credit to the hardworking men and women who frequent the vectorscript forum who are always helping me out.  For example, I know this is the script where I learned from @PatStanford the trick of naming something the current date down to the second to make sure you don't have a duplicated name.

 

 

  • 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
Answer this question...

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