TimLewicki Posted October 7, 2020 Share Posted October 7, 2020 I want to write code that will take a .txt file that may look like: N1 G1 G90 X0 Y0 Z3. N2 X1.2751 Y1.82 (G Code - can be thousands of lines long. Each new line starts with N__. Leading and trailing zeros are omitted.) Find every instance of X(and the value attached to it) and add a U(with the same value) afterward. For example, after running the software, the above will now look like: N1 G1 G90 X0 U0 Y0 Z3. N2 X1.2751 U1.2751 Y1.82 If been chasing various ideas and haven’t gotten very far. Link to comment Share on other sites More sharing options...
Funce Posted October 15, 2020 Share Posted October 15, 2020 You might be able to use Regular Expressions. Find: X(\d+\.?\d*) Replace: $& U$1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now