For animation and specific camera setup we need an extra camera for each shot. If you have not yet created a custom camera in the perspective viewport select > View > Create Camera From View (Ctrl+Shift+C). Rename the new camera and make it the active camera in the Viewport > Panels > Perspective > Your Camera Name. To activate the depth of field blur in the Attribute Editor go to the CameraShape node, activate “Enable DOF” in the Arnold section (not in the Depth of Field section, that’s for the Maya standard renderer) and increase the Aperture Size.
With the default focus distance of 1 cm everything becomes blurred in the IPR.
To find out the right focus distance we need to measure it. Let’s temporarily hide unnecessary objects by hitting the “H” key. Switch to the default working camera in the Viewport > Panels > Perspective > persp. Activate “Snap to points” from the toolshelf and > Create > Measure Tools > Distance Tools.
Click on the camera in the viewport and on the part of the object in your scene you want to have in focus.
Apply the measured distance to the “Focus Distance” attribute in the Arnold section of our camera …
… and this part becomes sharper.
The DOF blur effect is still intense – great for making adjustments. If you don’t want to measure again when the focus distance has changed, first parent the camera locator by MMB dragging it onto the Camera in the Outliner.
Rename the second locator to “Focus”. When you now move the camera or the “Focus” locator, the length value on the distance dimension tool should change. To connect the resulting length of the distanceDimension1 with the Arnold Focus Distance attribute in Camera1 just copy paste the following line into the “MEL” script field at the bottom left:
connectAttr -f distanceDimension1.distance Camera1Shape.aiFocusDistance;
Hit “Enter”. Important: To make the script work, your camera needs to be named exactly “Camera1” and the distance tool “distanceDimension1” in the Outliner. If you want to make it work with different names you need to adapt the strings in the script accordingly.
If the script was successfully applied you can see in the Attribute Editor the Focus Distance of Camera1 became yellow and is now linked to the Distance Tool.
For final rendering decrease the Aperture Size, I used here 2.