I wonder if it is possible to name a modifier before it is created with python.
Let me explain.
I would like to be able to add a modifier with python without ruining existing modifiers.
For example if i add a ‘BEVEL’ manually and don’t change the name before adding a ‘BEVEL’ with python then the python added ‘BEVEL’ will be named wrong for follow up commands.
I am not sure if this is helpfull, but it is possible to check objects for mods of a certain type and if there is one, change the name of it. I don’t know if there is a possibility to rename mods of uncertain type or name. So I am not sure if it helps…
for mod in ob.modifiers:
if mod.type == 'BEVEL':
mod.name = "oldbevel"
else:
pass
The easier way (in my opinion) would be to give the new mod a unique name and edit all the following commands for that name. But I am a noob myself, so maybe one of the pros has a better solution.
What I do is check if the name is already in use before I issue a .new() method to create a constraint. If so, I just use the existing constraint otherwise I create the constraint and immediately name it.
my_constraint = ob.constraints.get(con_name)
if my_constraint == None:
# Create a new constraint.
my_constraint = ob.constraints.new("FOLLOW_PATH")
my_constraint.name = con_name
my_constraint.use_curve_follow = True