I have a small business (just me) selling an inspection machine. The camera and lens work well, but I've had to print my own camera mount to get the lens further away from the CCD to get a good focus. The depth of field is extremely narrow, and I am interested in possibly making my own lens if I can buy the parts, and 3D print the barrel. I believe it's simple, but I really don't know anything about this. I downloaded software a year or two ago, I think called Synoptic. I dabbled, but don't know what I'm doing. The CCD is 1/3 inch, and it is placed six inches from the target, with the target being .7 inches diameter. The target is not normal to the lens, and is at a 30 degree angle. This angle causes problems with the top and bottom edges not being in focus. Is there a tutorial somewhere for software that I can freely download? Or, is there other reference material I should be reading?
Sounds like what you need is to tilt your lens to get everything in focus. Because the lens will be tilted, you'll probably need one with a larger image circle in order that it still covers your sensor when tilted, though you may find the existing lens has enough coverage.
Alternatively, try shifting the lens - that way, you can point the lens perpendicular to the target but not pointing straight at it - if you shift the lens away from being inline with the target, the image of the target moves away from the center of the image - but you can compensate for that by moving the sensor so it's where the image ends up. Again, this will usually need a lens with a larger image circle, so the shifted image of the target is still inside the image circle.
You would likely be foolish to make your own lens. Likely Edmunds Scientific http://www.edmundscientific.com/ will have everything you need. Make sure to be ready with the specifications of the lens you want when you contact them.
Depending on the subject you're photographing, you could try focus stacking: https://digital-photography-school.com/an-introduction-to-focus-stacking/
Or Light field cameras such as the Lytro (may be discontinued?): https://www.lytro.com/ https://www.bhphotovideo.com/c/product/801644830-USE/lytro_b5_0035_illum_light_field_digital.html
I would say it's cheaper and easier to find someone in China to help prototype a product for you. Googling found this http://www.optics-online.com/Custom/prototype.asp
Also try Thor Labs for optical components: https://www.thorlabs.com/