Skip to main content
12-Amethyst
June 6, 2023
Solved

How to loop a mapkey?

  • June 6, 2023
  • 2 replies
  • 4677 views

I have created a mapkey to open a .prt and import to .stp(refer config2.pro). I succeed on that one. But I also have several .prts to convert to .stp. so I copy the mapkey, pasted various instances and replaced the .prt names(config3). but it didnt work. 

RG_10671499_0-1686061816551.png

later i found some tools from here Repeatable Mapkey Generator – 4K Side and that one works.

how did that work mine gives error?

 

Best answer by RG_10671499

I also created a simple python script to automate the process.

def replace_text(input_file, input0_file, list_file, output_file):
 with open(input_file, 'r') as f_input, open(input0_file, 'r') as f_input0, open(list_file, 'r') as f_list, open(output_file, 'w') as f_output:
 input_text = f_input.read()
 input0_text = f_input0.read()
 list_lines = f_list.readlines()

 modified_text = input0_text.replace('XXXX.stp', list_lines[0].strip())
 f_output.write(modified_text)

 for line in list_lines[1:]:
 modified_text = input_text.replace('XXXX.stp', line.strip())
 f_output.write(modified_text)

 print(f"Replacements completed. Modified text saved to {output_file}.")

# Replace the file paths with your actual file names
replace_text('input.txt', 'input0.txt', 'list.txt', 'output.txt')

The input0.txt has the 1st instance of the fresh mapkey, i think this is larger when compared to next instances. so i made it special.

The input.txt is the next instances of the particular list. ( so you have to record the mapkey for 2 or 3 creo files)

The list.txt has all the information about what the files are to be affected by this mapkey.

Both input.txt and input0.txt should have same replaceable instance. I used XXXX.stp. Also they both should have an empty line at end of the file, so that next instance will copy to the next line. list.txt shouldn't have any empty lines.

 

The output.txt consists the mapkey code from the second line. Open this and delete the last \ in order to end the mapkey. Now you can copy and paste to the previously created mapkey.

Enjoy.

I attach some files this worked for me.

Let me know if you have any comments.

Thanks.

RG_10671499_0-1686067530515.png

 

RG_10671499_1-1686067622794.png

 

2 replies

12-Amethyst
June 6, 2023

LOL. I figured it out. The problem is, in order to loop/mapkey(continued) the there should be a ;\ I used ; only.

; only used for the end of the mapkey. Now I can loop.

RG_1067149912-AmethystAuthorAnswer
12-Amethyst
June 6, 2023

I also created a simple python script to automate the process.

def replace_text(input_file, input0_file, list_file, output_file):
 with open(input_file, 'r') as f_input, open(input0_file, 'r') as f_input0, open(list_file, 'r') as f_list, open(output_file, 'w') as f_output:
 input_text = f_input.read()
 input0_text = f_input0.read()
 list_lines = f_list.readlines()

 modified_text = input0_text.replace('XXXX.stp', list_lines[0].strip())
 f_output.write(modified_text)

 for line in list_lines[1:]:
 modified_text = input_text.replace('XXXX.stp', line.strip())
 f_output.write(modified_text)

 print(f"Replacements completed. Modified text saved to {output_file}.")

# Replace the file paths with your actual file names
replace_text('input.txt', 'input0.txt', 'list.txt', 'output.txt')

The input0.txt has the 1st instance of the fresh mapkey, i think this is larger when compared to next instances. so i made it special.

The input.txt is the next instances of the particular list. ( so you have to record the mapkey for 2 or 3 creo files)

The list.txt has all the information about what the files are to be affected by this mapkey.

Both input.txt and input0.txt should have same replaceable instance. I used XXXX.stp. Also they both should have an empty line at end of the file, so that next instance will copy to the next line. list.txt shouldn't have any empty lines.

 

The output.txt consists the mapkey code from the second line. Open this and delete the last \ in order to end the mapkey. Now you can copy and paste to the previously created mapkey.

Enjoy.

I attach some files this worked for me.

Let me know if you have any comments.

Thanks.

RG_10671499_0-1686067530515.png

 

RG_10671499_1-1686067622794.png

 

24-Ruby III
June 7, 2023

Hi,

just additional information.

https://www.ptc.com/en/support/article/CS114528 tells us that the length of mapkey code had a limit in the past.

12-Amethyst
June 7, 2023

257004 lines ðŸ˜®

i think that itself too much.