EpicJefferson published a full tutorial on how to make Arduino based 3d drawing pen with 3d printed enclosure. It can sedn data to other software like Processing and uses an external motion tracking system (like Optitrack in the video)
Full build guide and all the files can be found at: