Jump to content
Developer Wiki and Function Reference Links ×

How to change a sheet layer-sheet number?


sjm_htc

Recommended Posts

Hi all, I am trying to adapt a node I found on the forum which changes sheet layer sheet titles. I wish to adapt it to change sheet layer sheet numbers. What I have tried is to change 'object property index' from 159=Sheet Title to 158 which I hope is for the sheet number. I also changed the parameter from self.Params.sTitle.Value to  self.Params.sNum.Value. Which I hope is the parameter name for the sheet layer sheet number. I think both are incorrect. I have uploaded a test file where I am trying to create this node. Below is the code I am trying to hack together to create the custom node for changing sheet layer sheet number. 

 

#Created by MFarrell 02/02/18
#modified to sheet number sjm 12.08.2022
@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
    #Name
    this = Marionette.Node( 'Change Sheet Number' )
    this.SetDescription( 'Changes the Description value of a Sheet Layer' )

    #Input Ports
    obj = Marionette.PortIn( vs.Handle( 0 ), 'hLayer' )
    obj.SetDescription( "The input object" )
    sNum = Marionette.PortIn( '' )
    sNum.SetDescription( "Number of the sheet" )

    #OIP Controls

    #Output Ports
    value = Marionette.PortOut('hLayer')
    value.SetDescription( "Handle to the layer" )

#BEHAVIOR
            
def RunNode(self):
    #inputs
    obj = self.Params.obj.value
    index = 158
    sNum = self.Params.sNumber.value
    
    #script
    value = vs.SetObjectVariableString(obj, index, sNum)
        
    #outputs
    self.Params.value.value = obj

 

Batch Change Sheet Numbers_#2.vwx

Link to comment

I wrote one of those myself using VectorScript.  It seems it would be super useful. 🙂

 

Are you trying to change the stacking order or the sheet number?  Changing the stacking order is tricky.  

 

In VS the command is just SetName().  If I remember the number is actually the name in VS.  

 

The sheet title is SetObjectVariableString (layerHandle,159,'Sheet Name');

 

 

 

 

This might be helpful:

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



 

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