In plugdata, use one of the MIDI IN objects and route MIDI data from it (see example).
Play notes on this MIDI track using any usual method — keyboard, piano roll, etc.
MIDI OUT
Add plugdata to an empty instrument track.
In plugdata plug-in, use one of the objects that sends out MIDI data (see examples)
Create a second instrument track. Load an instrument that you want to receive MIDI from plugdata on this track. In the drop-down Instrument input menu select plagdata(a).
FX
In your project's Mixer panel (press F3 to toggle), add plugdata-fx as an insert effect to an audio or instrument track.
In plugdata, use [adc~] object to receive audio from your DAW (see examples).