I've had some custom
parts machined before and ate the cost for one part, knowing if it was something I could have a dozen or so made of and actually sell them, I may have been able to break even for that one part.
Design and setup are the big upfront costs. Once that's done, it's down to material and quantity prices, as already mentioned. One-off
parts are the most expensive. You've gotta get some other insane people in on those projects, to buy extra
parts and hopefully you'll break even, and make some personal connections.
As far as matching use with new gears, my experience has been that if the used gear isn't abnormally worn or damaged, it should be fine, possibly excluding high power or racing applications.
One example is my XR650L transmission. The bike and original engine had about 65,000 on it when the engine started to show signs of needing a rebuild. I went a little bonkers and bought an entire XR600R, just for the engine, and put that in the XR650L frame, but not before a rebuild.
Keep in mind, those gears had over 60,000 miles already. I used the XR650L primary gears (lower than the XR600R), and NX650 and FMX650 gears meshed with the original XR650L gears to change the transmission ratios, making a super wide five speed. That was probably 15,000 miles ago and I haven't had any problems from the transmission. New gears meshed with high mileage ones.
Another example is my pickup. The well worn, abused, and neglected T-18 transmission was missing a few teeth.
I had to replace the cluster gear (several gears made together, on one shaft), first and reverse gears. The rest of the gears were original, to my knowledge. That rebuild was 20,000-30,000 miles ago. No problems other than occasionally, third gear synchro, which was probably my fault during the rebuild as that was the first/only T-18 I've rebuilt.
If the gears have normal wear and no pitting, they'll be fine.