Not sure I understand why you need a script to unprotect traces.
Set your filter to allow for only nets & traces. Then With "Properties", un check the protection.
You should now have all traces unprotected.
I wanted to know if this should work because you can glue/unglue parts via scripting. Protecting/unprotecting seems like an equivalent feature that should work.
Currently I don't care about the net names or anything so just selecting everything and unchecking the box is fine. I can see cases where I might want to only select certain nets and that's where a script could come in hand to filter based on name, rule, or some other property.
I see now in the automation object explorer that it only says 'returns' the property not set or return so it is a read only property to automation.