I designed this to be used with the spare sensor that comes with the Tevo Tarantula kit. You can either use small screws (M2) to attach the switch, or as I do here, simply use 1.75mm filament to attach the switch to the enclosure. Screw the enclosure together with 3 M3 x 12mm screws and nuts. I used some short pieces of PTFE tubing on the ends of the enclosure, but this is by no means necessary.
Print the filament_runout_enclosure.stl twice. After printing you may want to sand the pieces down, so the fit together nice and flush.
I used the Z+ Port, therefore you need to set FIL_RUNOUT_PIN in pins_RAMPS.h to 19:
#define FIL_RUNOUT_PIN 19
In Configuration.h search for the FILAMENT_RUNOUT_SENSOR define and comment it out. If you want to use the default pinout, also invert the logic of the sensor and disable the internal pullup:
#define FIL_RUNOUT_INVERTING true // set to true to invert the logic of the sensor.
//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for
filament runout pins if the sensor is defined.
#define FILAMENT_RUNOUT_SCRIPT "M600"
More information about the Marlin configuration can be found here.
OpenSCAD file is attached and may be customized via Customizer in case you want to adapt it for a different switch, or your tolerances.
If you want to support me, feel free to leave a tip here on thingiverse, or use on of the following affiliate links (no extra cost for you, but I get comission on everything you buy) to do your shopping.