We present a new method to generate spatial motion constraints for surgical robots that provide sophisticated ways to assist the surgeon. Surgical robotic assistant systems are human-machine collaborative systems (HMCS) that work interactively with surgeons by augmenting their ability to manipulate surgical instruments in carrying out a variety of surgical tasks. The goal of "virtual fixtures" (VF) is to provide anisotropic motion behavior to the surgeon's motion command and to filter out tremor to enhance precision and stability. Our method uses a weighted, linearized, multi-objective optimization framework to formalize a library of virtual fixtures for task primitives. We set the objective function based on user input that can be obtained through a force sensor, joystick or a master robot. We set the linearized subject function based on five basic geometric constraints. The strength of this approach is that it is extensible to include additional constraints such as collision avoidance, anatomy-based constraints and joint limits, by using an instantaneous kinematic relationship between the task variables and robot joints. We illustrate our approach using three surgical tasks: percutaneous needle insertion, femur cutting for prosthetic implant and suturing. For the percutaneous procedures we provide a remote center of motion (RCM) point that provides an isocentric motion that is fundamental to these types of procedures. For femur cutting procedures we provide assistance by maintaining proper tool orientation and position. For the suturing task we address the problem of stitching in endoscopic surgery using a circular needle. We show that with help of VF, suturing can be performed at awkward angles without multiple trials, thus avoiding damage to tissue.