Spacing guitar frets

Hi, I don’t know if this is the right place to post that, and if it has already been posted (I didn’t find) but I hope it’s ok :slight_smile:

I’m currently working on a guitar model, and I’m searching a way to put the frets at the right place. As you probably know, they are not evenly spaced but the more you you go towards the bridge, the closer they are (spacing is multiplied by 0.944 each time, after my calculation).
Of course, I could duplicate each one and place them manually, but I’m pretty sure there is a better way. So I’ve made the first one and I searched how it would work with the array modifier based on an empty, but I can’t find a way to duplicate the frets and make them closer and closer, without changing their size.
So is this possible with the array modifier (and how), or is there another way ?

Thank you in advance :slight_smile:

One way is to have an object for each fret, object origins in their middle points, and then use the available formulas to distribute them. An example, adjust the script/formula as needed.



'''
dist(x) = s / (2 ^ (x/12) )

dist(x) = distance from bridge at the bottom end of the guitar to fret x on the neck
s = resting string length (distance from the zero fret “nut” at the top of the guitar to the bridge at the bottom of the guitar)
x = number of the fret being evaluated
12 = the number of frets per octave that occurs on every Guitar. 
'''

s = 6.51

import bpy

items = sorted(bpy.context.selected_objects, key=lambda x: x.name)
startpoint = items[0].location.x

for i, obj in enumerate(items):
    obj.location.x = startpoint
    obj.location.x = (s / (2 ** (i/12)))


Thanks. I have never used script in blender but I’ll try and tell you if I manage to do that.

I get how that works (I’m a IT student), and the spacing seems good, but I don’t get why my first fret is not at the right place at all. I’ll keep trying and I’ll get back to tell you.

The calculation doesn’t take the start point into account


In this one I made it so that the first fret is on the bridge. Length was matched with extra plane and looking up its X dimension.

JA is the man for this type of things … ( Just for thank him )

One thing I don’t get : in the loop, the line “obj.location.x = startpoint” seems useless to me, because “obj.location.x” is reassigned just below. Am I missing something ?

It’s not needed

I acheived what I wanted, for information there is my code :


s = 8.5

import bpy

items = sorted(bpy.context.selected_objects, key=lambda x: x.name)

startpoint = 4.25

for i, obj in enumerate(items):
    obj.location.y = (s / (2 ** (i/12))) - startpoint

Don’t look at the values, the guitar is not to scale so that’s not important. But by tweeking s and startpoint, I managed to place my frets where I want, starting from where I want.
Thank you again JA for your advices!