September 21, 2018, 4:07am
why is this code not working some_comp_node.name = some_comp_node.name.strip(“0”), i want to remove the zeros from suffixes .001 .002 .003 and so on.
i have tried storing the obj name in a variable first, str = some_comp_node.name
some_comp_node.name = str.strip(“0”)
do i have to split(’.’) first or something?
September 21, 2018, 4:57am
The code works, it is just not doing what you want. strip() removes leading and trailing characters - whitespace by default.
You probably want replace() or to split the strings apart. Using regex is left as an exercise to the reader.
September 22, 2018, 10:22am
thanks for the replay, i endup using:
`for obj in whatever:
if “.” in render_node.name:
suffix = obj.name[-3:]
stripp = obj.strip(suffix)
obj.name = stripp+ str(counter1)
if counter1 <= len( number_of_selected_objects):
counter1 += 1´
as part of a loop, and worked just fine.
obj.name = obj.name.replace(“0”,"") should do the job, how ever im no sure if it would give the unwanted result to leave a blank space in between the dot and the number. like so “obj_name. 1”