A method is described for performing a percutaneous operation on a patient to remove an object from a cavity within the patient. The method includes advancing a first alignment sensor into the cavity through a patient lumen. The first alignment sensor provides its position and orientation in free space in real time. The alignment sensor is manipulated until it is located in proximity to the object. A percutaneous opening is made in the patient with a surgical tool, where the surgical tool includes a second alignment sensor that provides the position and orientation of the surgical tool in free space in real time. The surgical tool is directed towards the object using data provided by both the first and the second alignment sensors.