It is a known limitation in SOLIDWORKS assemblies that you cannot make a piston phobic to the end of its path.
Below is a piston attached to a shaft with two square stoppers on either end.
The red piston can slide back and forth on the shaft.
Unfortunately, we cannot just tell SOLIDWORKS “avoid the two stoppers” or “do not touch the stoppers”
We can, however, use two “limit distance mates” limiting how far either side of the piston can go from the stoppers.
Limit distance mate number 1:
As you can see above, I created a limit distance mate to go from zero (where the two highlighted faces would be coincident) to a number larger than the length of the shaft. This limits the faces from passing over each other in ONE direction, so adding another limit distance mate on the opposite two faces (highlighted below) will limit the piston from passing the stopper in the other direction.
Limit distance mate number 2
Now the piston is free to slide back and forth along the shaft without passing the stoppers and you do not have to redefine the limit distance mate if the shaft length changes.
Application Support Engineer
Computer Aided Technology, LLC