We describe a new method to generate virtual fixtures for surgical robot control which provide sophisticated ways to assist the surgeon. Different spatial motion constraints for human machine collaborative systems can be implemented by using this method if we know the required geometric constraints and the instantaneous kinematics of the robot. It is independent of manipulator types: teleoperative or cooperative controlled; admittance or impedance type. Our method uses weighted, linearized, multi-objective optimization framework to formalize a library of virtual fixtures for task primitives. We set the cost function based on the user's inputs, and set linearized subject function based on a combination of five basic geometric constraints. In this paper, we also illustrate the implementation for two sample tasks, which are useful for surgical applications, and provide the experimental results for these tasks.