Is it possible to copy all edit bone properties to another bone?

Hi

I was just creating some small scripts to mirror/clamp/fix bone envelopes, bbone x/z size etc. so far I’ve only managed to do this by copying one value at time, something like this:

# copy settings
n.head_radius = b.head_radius
n.tail_radius = b.tail_radius
n.bbone_segments = b.bbone_segments
n.bbone_x = b.bbone_x
n.bbone_z = b.bbone_z    

But somehow it feels like it should be possible to just copy all bone properties at once… is this possible somehow?

Well, if you already have the list of attr you want, you can do so :

attr_list = ["head_radius", "tail_radius", "bbone_segments", "bbone_x", "bbone_z"]
for name in attr_list:
    setattr(n, name, getattr(b, name))

That said, if you want to do it for ALL attributes regardless of knowing them by advance, I don’t know yet a way of getting the list :thinking:

See you :slight_smile: ++
Tricotou

1 Like

You can use dir to get a list of all attributes. But you don’t want to stop if you encounter a read-only attribute.

attr_list = [name for name in dir(b) if name[0] != "_"]
for name in attr_list:
    try:
        setattr(b, name, getattr(b, name))
    except AttributeError:
        print("Cannot set attribute %s" % name)
1 Like

Thanks @tricotou and @ThomasL

I’ll have to digest these a bit, but I guess these both will work!