Jump to content
Developer Wiki and Function Reference Links ×

Rename multiple symbols


tca

Recommended Posts

Does anybody have a script that would allow me to rename multiple symbols? I have some library folders where every symbol carries an old prefix that I would like to change at once.

I've allready found some similar scripts for class renaming.

thanks in advance.

Tom

Link to comment

The following will change a substring in all symbols. Pass the handle to the first symbol in a folder to the FEO call to limit to a symbol folder.

-Josh

PROCEDURE MyScript;
VAR
newName	:STRING;
oldName	:STRING;

{---------------------------------------------------------------------}
FUNCTION ChangeModelSym(h:HANDLE):BOOLEAN;
VAR
symName:STRING;
labelH:HANDLE;
labelN:DYNARRAY[] OF CHAR;
BEGIN
symName:=GetName(h);
Message(Copy(symName, 1, 7));
IF Copy(symName, 1, Len(oldName))=oldName THEN BEGIN
	Delete(symName, 1, Len(oldName));
	Insert(newName, symName, 1);
	Message(symName);
	SetName(h, symName);
END;
END;
{---------------------------------------------------------------------}

BEGIN
oldName:='OldString';
newName:='NewString';
ForEachObjectInList(ChangeModelSym, 0, 2, FSymDef);		
END;
Run(MyScript);

Link to comment

Hi Josh,

Thanks for the answer.

I'm new to scripting so can you lead me a little further?

Where do I have to adapt the script to work with the following scenario?

a symbolfolder called 'test' which has several symbols in it starting with '00' (00-symbolname). These would have to be changed to '01' (01-symbolname)

Do I run this script directly from the resource browser?

Link to comment

Tom,

You can either create a new script with in the Resource Browser and run from the script palette you are prompted to create (Window>[Doc Name]>Script Palettes), or run the script as a text file from the Tools > Plug-Ins menu.

The ForEachObject call takes a handle (a unique ID tag assigned at script run) to the first symbol in a series. If you want the first symbol in a particular folder, replace

FSymDef

with

FInFolder( GetObject( 'The_Folder' ) )

This will look for an object called "The_Folder" and return a handle to the first symbol inside it.

Note this particular example is specifically for finding prefixes. If you want to change a suffix, you will need a couple more lines of code to find the start position of the substring.

-Josh

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