Hi @Alexey, thanks for your question and apologies for the delay.
If you need to have both a vertical and horizontal offset, then using the first block of code that pasted in will account for that. The second block that you pasted is a simplification and assumes that the receiver and transmitter are in the same horizontal plane.
I will copy in what you put and just give a comment just to walk through what is happening:
rx = rxList # get the first receiver in the list of receivers
P = rx.getP(mesh, 'Fz') # projection matrix that interpolates from the `Fz` grid where the magnetic flux is discretized to the receiver location
bprimary = fields[srcList, 'bPrimary'] # primary magnetic flux everywhere on the mesh
b0 = P*bprimary # compute the value of the magnetic flux at the receiver point
b0 = b0.real # grab the real component
Hope that helps!