The way I do this is using a program called SampleRobot:
http://www.samplerobot.com/ With SampleRobot, you give it the range of notes you want sampled, how many velocity layers, how long each sample should be, and how far into the sample you want it to look for loops.
You can even give it a list of patches in a hardware synth, press go and come back a day later when it's done them all.
I've used this program to sample the bulk of my hardware synths, so I'm now totally in the box synthwise.
For recording software synths it's more or less the same procedure, except that you need to get the sound out of your VST Host (SONAR/Cakewalk), and into SampleRobot.
For this I use it in conjunction with ASIO4ALL and
https://www.vb-audio.com/Cable/ ASIO4ALL presents VBAudio Cable as an ASIO device which SONAR/CbB can output to, and a Wave In device that SampleRobot can record.
Oh, and you'll also need some MIDI loopback device like loopMidi (
https://www.tobias-erichsen.de/software/loopmidi.html) so that the MIDI output from SampleRobot gets routed to the MIDI IN in SONAR/CbB.
It sounds pretty complicated, but it's really just about connecting everything up.
The results are very good. SampleRobot stores all the samples as raw WAV files so you can fine-tune/edit anything afterwards, re-record a note, or re-do the loop on a particular note.
It also allows you to export your project in a bunch of different formats, including Sfz (Dimension Pro/Rapture), SoundFont, Kontakt, and many others.