You have to know the ERD of the rim before you calculate the spoke length. The ERD is often published by the manufacturer for branded rims. Don't take too much notice of them on Ebay listings or Chinese sites. Every time I've used those, they've been wrong. Now I always wait 'til I've got the rim to check the ERD before I order the spokes. You can measure the inside diameter and add 5mm, which will get you close enough.
Once you have the ERD, you need the flange dimensions from the motor, then you enter them and the ERD into this spoke calculator. You can leave all the other parameters:
http://leonard.io/edd/