Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.
First constrain the compression spring's origin axis to the hole's axis and then create a custom work plane on the spring at the top of the spring or bottom as per need and should be offset from the origin work plane and now constrain the new plane to some flat geometry to set the height. To prevent spring rotating constrain another origin plane.
Hope this helps.
It is possible to constrain it without custom work planes. 1st constrain the springs origin axis to the hole (1st constrain.jpg). Then constrain the holes bottom plane to the spring end and set the offset to 1/2 the springs wire thickness (2nd constrain.jpg). Finally if you need to constrain the rotation; i usually constrain the spring end with an angle constrain to a feature plane or origin plane (3rd constrain.jpg) in that case i can specify the rotation angle of the spring.