I've been needing/asking for this for years. There is no way to do this. Please vote for enhancement request
Sorry. SPR# 527618
as noted, there is no known way.
currently we address this through user training and relying on the customproperty manager tab. we have our tbs set up so that only the custom properties that we want the user to edit are shown.
these fields in the property tabs can also be driven by lists and databases ( we don't), but that may help your situation.
none of this stops someone from going to the file->properties and changing something. but that is what the training is for.
If the variable is one way then we can create new variables (not set custom property during creation of variables) and use the same for datacard. As it will not overrite the data's.
A couple years back at SolidWorks World it was stated during the CAD Manager bootcamp by the SW Team that adding function to lock custom properties in SolidWorks would be an extreme undertaking that they were unwilling to take on at that time.
If adding the ability to lock custom properties would require that they have to reprogram SolidWorks from the ground up, then maybe SW should add hidden property capabalities like a previous CAD software I have used did. Set it up so hidden properties can only be accessed through a custom add-in using the API or ePDM. This way the users cannot change what they cannot see.
I have submitted an ER# 1-2629414848 asking for this.
I have come across locked custom properties after importing a part into a part and checking the "transfer > custom properties > file properties". This creates greyed out lines on properties that you cannot edit where the properties values are controlled by the values in the other part. This seems close to the functionality you need for making properties that are controlled by PDM.