@@ -28,6 +28,17 @@ def writeifexists(file, section, src_item, dest_item = "None"):
2828 if dest_item == 'None' : dest_item = src_item
2929 val = ini .find (section , src_item )
3030 if val : file .write ("%s = %s\n " % (dest_item , val ))
31+
32+ def insert_after (key , new_line , section ):
33+ match = re .search (key , section )
34+ if match :
35+ # Find the end of the line that contains the match
36+ line_end = section .find ("\n " , match .end ())
37+ if line_end == - 1 : line_end = len (section ) # match is on the last line
38+ else :
39+ line_end = len (section ) # place it at the end
40+ new_line += "\n "
41+ return section [:line_end + 1 ] + new_line + section [line_end + 1 :]
3142
3243force = 0
3344dialogs = 0
@@ -452,6 +463,22 @@ def ini_preamble():
452463 section = re .sub ("MAX_SPINDLE_SPEED" , "MAX_SPINDLE_0_SPEED" , section )
453464 if re .search ("MIN_VELOCITY" , section ):
454465 section = re .sub ("MIN_VELOCITY" , "MIN_LINEAR_VELOCITY" , section )
466+
467+
468+ # Copy values from TRAJ
469+ if not re .search ("DEFAULT_LINEAR_VELOCITY" , section ):
470+ val = ini .find ("TRAJ" , "DEFAULT_LINEAR_VELOCITY" )
471+ if val :
472+ section = insert_after ("MAX_LINEAR_VELOCITY" , f"DEFAULT_LINEAR_VELOCITY = { val } \n " , section )
473+ if not re .search ("MIN_LINEAR_VELOCITY" , section ):
474+ val = ini .find ("TRAJ" , "MIN_LINEAR_VELOCITY" )
475+ if val :
476+ section = insert_after ("MAX_LINEAR_VELOCITY" , f"MIN_LINEAR_VELOCITY = { val } \n " , section )
477+ if not re .search ("MAX_LINEAR_VELOCITY" , section ):
478+ val = ini .find ("TRAJ" , "MAX_LINEAR_VELOCITY" )
479+ if val :
480+ section = insert_after ("MIN_LINEAR_VELOCITY" , f"MAX_LINEAR_VELOCITY = { val } \n " , section )
481+
455482 newini .write (section )
456483
457484 # TODO update-ini 1.1 --> 1.2:
@@ -465,7 +492,7 @@ def ini_preamble():
465492 #
466493 # copy [TRAJ]DEFAULT_LINEAR_VELOCITY -> [DISPLAY]DEFAULT_LINEAR_VELOCITY
467494 # move [TRAJ]MIN_LINEAR_VELOCITY -> [DISPLAY]MIN_LINEAR_VELOCITY
468- # rename [TRAJ, DISPLAY]MIN_VELOCITY --> MIN_LINEAR_VELOCITY
495+ # ~ rename [TRAJ, DISPLAY]MIN_VELOCITY --> MIN_LINEAR_VELOCITY~
469496 # copy [TRAJ]MAX_LINEAR_VELOCITY -> [DISPLAY]MAX_LINEAR_VELOCITY
470497
471498 #These sections don't need any work.
0 commit comments