-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-write of Search and Replace #19796
base: main
Are you sure you want to change the base?
Conversation
Added some options: - Replace the 'First Instance Only' of the Search term. - Limit the Search to a layer range. - 'Ignore StartUp G-code' and 'Ignore Ending G-code'
Thanks, we will take a look when we are not overbusy 😊 |
Update a description Update SearchAndReplace.py Fixed the "descriptions". Cura didn't like the dashes or backslashes.
146f2f9
to
349c528
Compare
} | ||
} | ||
}""" | ||
|
||
def execute(self, data): | ||
curaApp = Application.getInstance().getGlobalContainerStack() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style: cura_app
instead of curaApp
.
Or better, since you are actually getting the global container stack: global_stack
|
||
for layer_number, layer in enumerate(data): | ||
data[layer_number] = re.sub(search_regex, replace_string, layer) #Replace all. | ||
#Find the raft and layer:0 indexes-------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange comment style. Please use the same style of comments as the rest of Cura.
I am somewhat surprised Python does not complain about the indentation; strictly speaking this indentation ends the previous codeblock.
replaceone = True | ||
break | ||
if replaceone: break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, this condition is never met because we're already broken out of the for loop. As a matter of fact, it seems to me that the whole replaceone
variable is useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was vestigial code. There may have been a second "for" in there and I used the second 'break' to back all the way out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There seems to be a lot of unnecessary code duplication after line 170 |
Update SearchAndReplace.py Changed comments. Revised code below line 170. Changed 'curaApp' to 'cura_app'
fbe4c39
to
be509b6
Compare
Thanks @fieldOfView. A quick squash and all the changes are in that last commit. |
Added some options:
Description
Added flexibility to the script. The options still allow a full Search and Replace as well as a limited Search and Replace.
Type of change
How Has This Been Tested?
I have been using this version for a year with multiple Cura versions.
Test Configuration:
Win10 Pro on a laptop.
UM Cura 4.13.1 to 5.9beta.
Checklist: