If you were replacing one motor with the same motor, I recall that the Sondors guys were able to just swap out the motor cores, leaving the outer case connected to the spokes, but I've never done it so don't take my word for it. Some of these motors have plates that pry off. Some have plates that screw in like the doors in an HG Wells Martian space craft. I hear those take 3 foot levers to spin loose/
But changing a hub motor by re-spoking it, that's a big undertaking. I moved a hub from a regular wheel to a fatbike wheel, and that took a patience and blind faith that I could do it as a novice. If it's the same motor, at least you know what spoke lengths are needed, but for a typical install into a different rim, there's a lot of measurements needed.