[Al...] Posted October 28 Share Posted October 28 Hi , is there an easier way to batch rename this as an example, we have copies up to 140 in a cluster but we wanted to rename output. example output is: 5.1 Line 28 5.1 Line 29 5.1 Line 30 5.2 Line 28 5.2 Line 29 5.2 Line 30 5.3 Lin 28 5.3 Line 29 5.3 Line 30 We want it to appear as : Line 28.1 Line 28.2 Line 28.3 But as you can see about the output is staggered and we have to manually click each output say all 28 to group them together. We tried rename by character sequence, but we could not find a way to group all 28 together. Link to comment Share on other sites More sharing options...
[Ja...] Posted October 28 Share Posted October 28 I could imagine python code to deal with this if the number of characters remains consistent . This also could be achieved in excel. Essentially looking at characters within the string and re concatenating Sadly i cant easily share any code or snapshots of how to , but if you look for LEFT , MID, RIGHT and CONCATENATE commands in excel i think you will get it. Something like. concatenate ( mid(text,5,7), left(text,2,2)) Link to comment Share on other sites More sharing options...
[Ti...] Posted October 29 Share Posted October 29 (edited) If you create a xlsx excel file with all the old names in column A and all the new names in column B you can use this script...you will need to somehow install the openpyxl and tkinter python modules into your gom software. import gom import openpyxl from tkinter import Tk from tkinter.filedialog import askdirectory from tkinter import filedialog, Tk # location of excel file excel_path = filedialog.askopenfilename(title='Select the Excel file that contains the name changes') # open excel file wb = openpyxl.load_workbook(excel_path) ws = wb.active # for loop from row 1 to last row in excel sheet for i in range(1, ws.max_row + 1): try: old_name = ws['A' + str(i)].value # col A is old names new_name = ws['B' + str(i)].value # col B is new names try: # gom function called that will change the name gom.script.sys.rename_elements_by_character_sequence( character_sequences={'from': old_name, 'to': new_name}, elements=[gom.app.project.inspection[old_name]]) print(old_name + ' ----> ' + new_name + ' changed successfully!') except: if old_name == new_name: print(old_name + ' ----> ' + new_name + ' duplicate, not changed!') except: pass wb.close() Edited October 29 Link to comment Share on other sites More sharing options...
[Se...] Posted October 29 Share Posted October 29 (edited) As mentioned before, a small python script (more information about the API can be found here: https://zeissiqs.github.io/zeiss-inspect-addon-api/) should do the job For this particular case this would work: for e in elements_to_rename: gom.script.sys.edit_properties ( data=[gom.app.project.inspection[e.name]], elem_name=e.name[4:]+e.name[1:3]) Hope this helps Edited October 29 Link to comment Share on other sites More sharing options...
[Jo...] Posted October 30 Share Posted October 30 If you are using ZEISS INSPECT 2023, you can go to OPERATIONS --> ELEMENTS--> Rename by expression, Rename and Number and Rename by character sequence. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in