I wouldn’t do this through scripting. Instead, adjust the "spacing" property of your brush settings so that each mark will be 6 pixels apart. Then there are two ways to make the marks: either just click at the beginning and shift-click at the end of your desired line, or else create a line using the pen tool, and then use "stroke path" to make the marks along it.
I did indeed think of that, but photoshop adjusts the spacing by a precentage, not a pixel amount. Is there a way to calculate a pixel amount from the percentage? If there is then it would be alot faster. If not, then I would think a simple loop in PS scripting could get the job done.
I just experimented more with the spacing property and found that the percentage is based off the brush size which IS based off of pixels. If the brush size I'm using is 30px, I set to spacing to 20% to get 6 pixels. What if I have an ugly brush size like 18? That would give me a percentage of 33.333333333333333333 and so on. This isn't far from exact, but after 400 marks it adds up.
Is this a one-off, or do you need to do it many times? To do it just once, I’d just make a single brush mark, then duplicate the layer, move it 6 pixels, and merge down. Then I would duplicate the layer, move 12 pixels, and merge. Duplicate the layer, move 24 pixels, and merge. move 48 pixels. move 96 pixels. move 192 pixels. And then possibly add another couple brush strokes at the end.
There is not a simple scripting solution because a brush stroke can be scripted directly. I can think of several workarounds, two of which jacobolus has already suggested.
A new suggestion would be to try creating a path and then stoke the path with your brush. If that looks like you want it a script could then move the path 6 pixels and stroke it again. This has the advantage of not needing to create new layers and merge so should be faster. The disadvantage is the stoked path may not look the way you want.
If that doesn't work or you don't like that approach, I agree with the setting the spacing as a percentage of the brush size. All the stokes are made at one time and your done.
If you don't like that one need to do this more that once I would suggest that instead of merging down after each dupe you create an action that dupe the brush layer and moves it six pixels. The create another action that play the dupe'n'move action as many times as you need. You can also add your choice of how to merge to that last action if wanted.
This might work, but I think it could be tricky. A single click of a simple brush created a 60 kilobyte opaque and undocumented "raw data" blob in the resulting action. Reverse engineering the format could be difficult.
Easier would be to record an action of a single brush click, and then make a script that incorporated a "play action" step.
Europe, Middle East and Africa