Can I use rivets to attach electrical boxes to Purlins?
The code requires that the box be &quot;rigidly and securely fastened&quot; to the purlin.  Rivets seem OK to me, and I think would seem OK to most inspectors.  Having some specs on the mechanical strength of the rivets might help you if there's a question.
Rivets are specifically mentioned as an acceptable way to fasten a box to the frame of a ceiling grid.  To me that helps you argue that they are OK to attach to your purlin.  On the other hand, the inspector could argue that the ceiling gives the box some protection and something more rigid and secure is needed exposed on a purlin.