I focus on Assembly documents only because they are the main source of referencing other documents as their components. Drawings also reference other documents, but we are starting from the main drawing that references this part, and I don't expect that there would be any other drawings in the same directory that reference this part directly. If you expect there to be, that can be changed. The only way another Part document in the same directory would be referencing this part is if it were derived into it, which in my opinion would be rare. But that too can be changed, if you expect that scenario. I was mostly trying to avoid processing tons of extra files that did not need to be processed, because this type of routine can be pretty taxing on system resources, or possibly even freeze up your computer, if not handled properly.
Also, the code I posted only searches within the one directory (same directory as drawing's model), and does not step down into sub-directories. That can easily be changed though, by changing the option at the end of the 'GetFiles() method, within the 'GetWhereUsed' function, from 'TopDirectoryOnly' to 'AllDirectories'. Again my choice there was to limit the process, so it would not overwhelm my system while performing the tests.
My code also assumes there is just one 'model' being represented by the 'active' drawing. That's how we always do our drawings, but I realize that's not how everyone does it. I have other Functions or getting drawing model(s), depending on the need/situation. Other variations assume multiple models, and may return an ObjectCollection (or similar) of all the 'model' documents found (or filtered to one type of 'model').
Of course it can all be modified in any ways needed to suit your individual needs. I was just offering one idea and possible process that seemed logical to me, in my situation, and that works just fine for me. In my example tests, I have a drawing of a part in a folder where I have lots of files for testing. That part was also used within 4 other assemblies in that folder. When I run this rule, the mouse pointer swirls for a few seconds, then it inserts a text note at the lower left corner of my drawing sheet that starts with "USED IN:" on the first line, then lists the 4 part numbers in the following lines below that, for the other 4 assemblies that are referencing that part, within that directory. Since it seemed to work OK for me, I thought it would at least be a good starting point for others to start from there and modify the code as need to suit their individual needs. If you or anyone else needs to modify any part of the functionality of that code, but are not sure how to modify it, you can always request different functionality, and if I have time, I will attempt to modify it that way for you, if it is possible, and if I know how.
Wesley Crihfield

(Not an Autodesk Employee)