You can see my thick foam in the pic.
Carefully and tactfully lay out your project. Draw around your components with a marker. Cut inside the lines for a snug fit. Use a sharp exacto knife(I ordered one with the foam). When you have your cutouts, pick the layers apart so that all your components are at your desired depth in the foam, and push the thin cutout back where it came from. You can scarcely tell it was cut. The material 'heals' itself.
Best wishes. I actually had a thread on this earlier.
You might use the search feature and get more info by searching for "custom gun case".