The central concept here is the conversion from polygonal meshes (such as .stl) to boundary representations (as in STEP files). It is not a trivial conversion. Here's an article by Andrey Tumanin that should help. I believe he's written more on the topic, but was unable to find the papers.

Only top voted, non community-wiki answers of a minimum length are eligible