I have a wheel I CNC milled out of foam and I need to mount a motor to it. I designed and printed a part that would attach the motor to the foam, but I anticipated that the wheels would be wood back then. It connects to the wheel using screws, but it does not seem like screws would hold well in foam because the foam can't hold threads. Is there any other way to do this? I was thinking of using longer screws with nuts on them, but I am open to other ideas.
Using a longer screw with fender washers may work. You could try soldering a pin or something to the washers to avoid slippage. Then just clamp with a longer bolts.
I'd be concerned that adhesives may eat away at the foam. You'd have to try a couple different kinds first.
Do you have a motor with a threaded shaft?
I would design a hub with a flange to fit against the side of the wheel and use an adhesive that's chemically compatible with the foam and has good bonding strength to metal. 3M has some solutions that we've used for bonding foam sheets. You'll want to take advantage of the fact that adhesives are strongest in shear rather than tension/peel. You could also have an end plate with adhesive that would bolt through the foam wheel creating a "sandwich". The torque should be transmitted by the adhesive surfaces since the bolts will tear up the foam.
If you want a mount that is removable, use an adhesive that's soluble.