Jump to content
  • 8

Wishlist - Custom automatic viewport naming


Gregovitch

Question

Correct viewports naming can be quite useful, especially when you use the class visibility feature in the organization palette. For the moment the only automatic viewport naming is setup to: "Viewport number/Sheet number". 

 

I personally find it very weird because when I am searching my viewports in the organization palette it makes more sense to me to first see the sheet number then the viewport number. This is a personnel preference off course, but would it not be marvelous if we could have multiple selection of automatic viewport naming? Maybe something in the document preferences?

 

It would be great to have a automated viewport naming that would change when ever there are changes. That would save me so much coordination time.

 

Thanks

Edited by Gregovitch
  • Like 2
Link to comment

16 answers to this question

Recommended Posts

  • 0

I can't write scripts but If you have the script, or can copy it from this forum, then importing it into vw is very easy. There are two ways to do it. The simpler way is file specific and the other slightly more involved way allows the script to be used on any open file.

 

File specific method: (Good for scripts that you are unlikely to used elsewhere, or good to bring into template files so will be available in any files created from the template).

  1. Go to the resource manager.
  2. Hit "New Resource" in bottom left of window
  3. Choose new script
  4. Select a script palette to place the new script in, or choose "New Palette"
  5. Assign a name to the script
  6. Paste the script into the script editor and hit ok.

Double click on the script to activate it.

 

To display the palette in your workspace (rather than just in the RM), go to the Window menu and at the bottom under script palettes put a check mark next to the palette you want to see in the workspace.

 

This process makes the script accessible in the file you are working on only. You can import into other files via the RM just like any other resource.

 

To add the script as a plugin to your workspace as a menu command so they are useable with any file at any time:

  1. Go to the Tools menu and hit Plug-ins>Plug-in manager.
  2. Hit New and name the new plug-in. Hit ok.
  3. Hit edit script and paste the script into the script editor.

    This brings the plug-in into your VW but you still need to add it to your workspace to use it:
  4. Close the Plug-in Manager and go to Tools>Workspaces. 
  5. Edit the workspace you want to add the new plug-in to.
    In the list of menu commands on the left find the plug-in (probably under "Miscellaneous".
  6. Drag the plug-in across to the right and place it in the Menu where you want it and hit OK.

The script is now available in your workspace. Single click on it to activate it just like any other menu command.

 

  • Like 2
Link to comment
  • 0

So yes I just did a quick test on both Section viewports and Detail viewports and the rename script seems to be working without messing with the smart marker navigation. 

 

@Andy Broomell You can start renaming your vps again 🙂

 

Kudos to @michaelkfor writing the script in the first place and @Matt Panzerfor submitting the bug report.

 

There is another similar script that Michael wrote that will rename all sheet layer viewports in a file. This one is super handy too!

 

I think it goes like this. (Not sure if it's the most up to date version).

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




 

Edited by Boh
  • Like 1
Link to comment
  • 0

I'm never sure I'm running the most recent version of my scripts.  I often have to check here to make sure. 🙂

 

Here's is the one in my workspace:

 

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

 

I use it in conjunction with this one to renumber sheet layers.  So after you add, delete or reorder sheet layers you don't have to type in the new Sheet Numbers.  This may have developed a new bug in 2021.  It sometimes omits the last two sheet layers.  But not always.  Sigh.  This requires a little more explanation.  If anyone thinks it would be useful let me know and I'll write something up.

 

 

{Badly scripted by Michael Klaers}
{March 2020}

PROCEDURE RenumberSheetLayers; 

VAR
	
LayerInQuestion
:HANDLE;

LyrTypInt, Counter, StackOrderBegin, StackOrderEnd, RenumStart, 
RenumCount, HowManyLayers, NumDesignLayers, id, item  
: INTEGER;

SheetPrefix, SheetSuffix, NewName, TempString
: STRING;

Bool 	:BOOLEAN;

{******************************** The ever confusing dialog handler ****************}
PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
BEGIN
	CASE item OF
		SetupDialogC:
			BEGIN
				Bool := GetSavedSetting('SLRename','StackOrderBegin',TempString);
				SetEditInteger(id,6,Str2Num(TempString));
					
				Bool := GetSavedSetting('SLRename','StackOrderEnd',TempString);
				SetEditInteger(id,7,Str2Num(TempString));
					
				Bool := GetSavedSetting('SLRename','SheetPrefix',TempString);
				SetItemText(id,12,TempString);
				
				Bool := GetSavedSetting('SLRename','RenumStart',TempString);
				SetEditInteger(id,13,Str2Num(TempString));
					
				Bool := GetSavedSetting('SLRename','SheetSuffix',TempString);
				SetItemText(id,14,TempString);
			END;
		1:
			BEGIN
					
				Bool := GetEditInteger(id,6,StackOrderBegin);
				Bool := GetEditInteger(id,7,StackOrderEnd);
					
				GetItemText(id,12,SheetPrefix);
				Bool := GetEditInteger(id,13,RenumStart);
				GetItemText(id,14,SheetSuffix);
					
			END;
			2:
				BEGIN
				END;
	END; {Case}
END; {Dialog Handler}

{******************************** The slightly less confusing dialog layout ****************}
PROCEDURE MakeMeADialogBox;
BEGIN
	id:=CreateLayout('Renumber Sheet Layers',TRUE,'OK','Never Mind');
	
	CreateStaticText(id,4,'First',-1);
	CreateStaticText(id,5,'Last',-1);
	CreateEditInteger(id,6,1,6);
	CreateEditInteger(id,7,1,6);
	CreateStaticText(id,9,'Prefix',-1);
	CreateStaticText(id,10,'Num',-1);
	CreateStaticText(id,11,'Suffix',-1);
	CreateEditText(id,12,'A',6);
	CreateEditInteger(id,13,0,6);
	CreateEditText(id,14,'',6);
	
	SetFirstLayoutItem(id,4);
	SetRightItem(id,4,6,0,0);
	SetBelowItem(id,4,5,0,0);
	SetRightItem(id,5,7,0,0);
	SetBelowItem(id,5,9,0,0);
	SetRightItem(id,9,10,1,0);
	SetRightITem(id,10,11,2,0);
	SetBelowItem(id,9,12,0,0);
	SetBelowItem(id,10,13,0,0);
	SetBelowItem(id,11,14,0,0);
	
	SetHelpText(id,4,'Stacking order of first sheet to be renumbered');
	SetHelpText(id,6,'Stacking order of first sheet to be renumbered');
	SetHelpText(id,5,'Stacking order of last sheet to be renumbered');
	SetHelpText(id,7,'Stacking order of last sheet to be renumbered');
	SetHelpText(id,9,'New prefix for renamed sheet layers');
	SetHelpText(id,12,'New prefix for renamed sheet layers');
	SetHelpText(id,10,'New starting number for renamed sheet layers');
	SetHelpText(id,13,'New starting number for renamed sheet layers');
	SetHelpText(id,11,'New suffix for renamed sheet layers');
	SetHelpText(id,14,'New suffix for renamed sheet layers');
END;

BEGIN 								{**** MAIN ****} 


MakeMeADialogBox;	
	
item := RunLayoutDialog(id, Dialog_Handler);

IF item = 1 THEN
	
	BEGIN
		{MESSAGE	('Stacking Begin: ',StackOrderBegin,CHR(13),
				'Stacking End: ',StackOrderEnd,CHR(13),
				'Prefix: ',SheetPrefix,CHR(13),
				'RenumStart: ',RenumStart,CHR(13),
				'Suffix: ',SheetSuffix);}
				
		
		Counter := 1;
		LayerInQuestion:=FLayer;
		HowManyLayers := NumLayers;
		RenumCount := RenumStart;

	For Counter := 1 to HowManyLayers DO			{Step through every layer, including Design Layers}
	BEGIN

		LyrTypInt := GetObjectVariableInt(LayerInQuestion,154);


		{***************************************************************************}
		{Layer type 1 is a design layer.  It counts them from the bottom of the stack to the top.
		Ignore and go to the next layer.  
		But count how many design layers there are. You'll need that later.}

		IF LyrTypInt = 1 THEN
			Begin
			NumDesignLayers := Counter;
			End;

		{***************************************************************************}
		{Now we're in business.  Layer type 2 is a Sheet Layer
		Sheet Layers are counted by stacking order from top to bottom.}

		IF LyrTypInt = 2 THEN
			BEGIN
			
			IF (StackOrderBegin <= (Counter-NumDesignLayers)) AND ((Counter-NumDesignLayers) <= StackOrderEnd) THEN
		
				BEGIN
					NewName := CONCAT(SheetPrefix,Num2Str(0,RenumCount),SheetSuffix);
					SetName(LayerInQuestion,NewName);
					RenumCount := RenumCount + 1;
				END; {IF counter is in change range}
			
			END; {If LyrTypInt is 2 (i.e. Sheet Layer}
			
{***************************************************************************}			
			
		LayerInQuestion:=NextLayer(LayerInQuestion);
		
	END; {1 to number of layers}	

	SetSavedSetting('SLRename','StackOrderBegin',Num2Str(0,StackOrderBegin));
	SetSavedSetting('SLRename','StackOrderEnd',Num2Str(0,StackOrderEnd));
	SetSavedSetting('SLRename','SheetPrefix',SheetPrefix);
	SetSavedSetting('SLRename','RenumStart',Num2Str(0,RenumStart));
	SetSavedSetting('SLRename','SheetSuffix',SheetSuffix);
					
	
END; {If user clicked OK}

END; {main} 

RUN(RenumberSheetLayers);



 

Link to comment
  • 0

I think the rename all vp script you just posted is slightly out of date as the one I posted calls up som 2018 edits that the one you posted doesn't have. Though not sure it makes much difference 🙂

 

What numbering standard does the renumber sheet layers script use? Or is this customisable?

 

Cheers

Link to comment
  • 0

One of these days I'm going to sort through all the various versions of my scripts and get them organized 🙂 

 

I've been able to keep version numbers of the plug-in objects so I don't accidentally use an old tool, but when I started writing scripts I never thought there would be more than a few or that they would need to be updated…

 

I bet Pat, Josh, Sam, Julian, and Carlotta have this all figured out!

 

About the script:  It is customizable. 

Sheet layers have a Sheet number (this script will change that), a Sheet Title, and a "stacking number".  (It's probably really called something else)

 

For example you might have the following sheet layers:

 

Sht-1    Cover                            1

Sht-2   Construction Notes      2

Sht-3   First Floor Plan              3

Sht-4   Elevations                     4

Sht-5   Sections                        5

 

 

 

0.  Sort the sheet layers by stacking number.

1.  Organize the sheet layers in the stacking order you want.

2. Run the script.

3. Enter the first stacking number and the last stacking number you want to change.

4. Enter a prefix

5.  Enter a suffix.

 

In a simple example, if you want to make those be A1 through A5 you would run the script and enter these values:

 

image.thumb.png.8055f0fe057d95de6d9f951b4734ea58.png

 

Once you run it your sheet layer list would look like this:

 

image.png.a9583e88d0e4991aad6ce3d6172aa669.png

 

If you needed to add another cover page and you wanted to change it to A1 through A6 you have to run a dummy step.  Use a different prefix  or add a suffix.  i.e., change them to B1 through B6 or A1x through A6x.  Then immediately run the script again.  It will remember all your last settings.  Change the B to A or delete the X and run it again.  This is just to avoid the problem of giving a sheet layer a name that already exists further down the line.  (I could have coded around this problem, but there are other things to do 🙂 )

 

Finally if you add 3 more pages of elevations and you want to change it to A4.1 through A4.4 you would start with something like this:

 

image.thumb.png.93a916d6a655da32cee3777c93c31ad7.png

 

Start with number 4 go through number 7.  Make the prefix be A4. and then start the numbering at 1.

 

That will give you this:  

image.png.a23ca7e019a0df1c9b082eb47022300a.png

 

It's not perfect but it's sooooo much faster than typing in new sheet numbers every time you add or delete a sheet!

 

 

  • Like 1
Link to comment
  • 0

 

On 8/16/2021 at 11:46 AM, cberg said:

Here is a VW2020 file with the actual script embedded.  As mentioned above, you access it through a custom folder in the Resource Manager Scripts Pulldown Menu. 

 

Thanks Cberg and all the persons who wrote this script. It works great.

 

I have 2 last questions:

- How should I change the script if I would like to add some / (or any other separators) in the new name between the sheet name, the viewport number and the viewport name?

- Is there a way to change all the viewports name in one action or do I manually need to select each of those viewport on each of the sheets and run the script while having them selected (feels like a long process)

 

 

Have a good day

 

 

Edited by Gregovitch
Link to comment
  • 0
1 hour ago, Gregovitch said:

- Is there a way to change all the viewports name in one action or do I manually need to select each of those viewport on each of the sheets and run the script while having them selected (feels like a long process)

 

This is how I use the script now. 🙂   In the script editor, line 43 delete & (SEL=TRUE) so that it looks like the line in the first script in the post above.

 

 

1 hour ago, Gregovitch said:

 

- How should I change the script if I would like to add some / (or any other separators) in the new name between the sheet name, the viewport number and the viewport name?

 

 

 

In the script editor look at line 32:      SetName(h, CONCAT(ViewportLayerString,' ',VPNum,' ',VPDwgTitle));

 

The syntax for a CONCAT is CONCAT( something, something else, another thing entirely);  Commas between everything.  The values either need to be string variables or constants or any string value between single quotation marks.  In the case above it's

 

Sheet Layer Number as a variable - comma - single space surrounded by single quotes ' ' - comma - Viewport number variable - comma - ' ' - comma, etc.

 

Watch your commas and single quote marks and you can add the complete works of Shakespeare to your viewport names.

 

Post back if you run into trouble 🙂 

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