Hello! Welcome to the forum! It looks like there are a few posts on this topic already. I would check out the linked post below to get you started on your task.
For further investigation and future scripts, I would look at other posts on the forum, the Dynamo Primer, and Revit API Docs if you start working with custom Python nodes.