Dynamic Railing

I’m fairly new to SketchUp, so forgive me if what I’m asking isn’t possible within the application or if it seems like I don’t have a clue.

I’m trying to create a dynamic component for modeling railing. I’ve managed to get things mostly setup correctly, but I can’t figure out how to get the correct spacing I need. The spacing between the balusters must be 3 7/8" regardless of scaling length. The balusters on the ends, must be spaced no less than 1 3/4" but no greater than 3 7/8" from the end of the railing. I’m also trying to get the balusters on either end of the railing to be equal distance from the end of the railing (at least within 1/8") so that the spacing on each end is uniform.

I’ve managed to get the scaling to work while maintaining proportions of specific child components. I think I’ve figured out the copying, but the spacing I’m trying to achieve is really causing a headache. I’ve uploaded my project file, if anyone has a suggestion, I’d greatly appreciate the help!

Thanks in advance!
Railing Component.skp (178.5 KB)

use floor or int to get lowest integer return for number of slats
get the remainder from the overall length and divide by 2
make sure largest is 1.75 or above

if 1.75, then need to do same to other end

so if copy =copies(that is an integer not a real number) and remainder is 1.75
then this works:-
rails.skp (127.9 KB)

if you want an even space when 1.75 at both ends after first and before last, then need to account for this, please reply if required or use the solution above

I know you’re asking about creating dynamic components, but have you looked at Profile Builder at all for doing parametric railings? It might be an alternative way.