How to convert the size of the world coordinates to pixels on the screen?

For example, a distance of 10 units, regardless of camera rotation, translates to how many pixels on the screen?

I tried this way, but I don’t know how to get rid of the rotation value of the camera, I believe it’s not the best way

You would need to project first from 3d space to screen each points and then mesure the distance between both 2d points.