Run Dynamo Script on entire folder of dwg's

The main function is the one that gets all the DWGs from the folder and subfolders recursively.
Python has the os.walk() method that does exactly what we need (L206-209)
For each DWG then it calls the inner function that does all the job.
In this case there a lot of inputs to be as flexible as possible. In Dynamo the CoordinateSystem method to create a BlockReference is basically providing the same inputs but it is using a single object to derive all of them.

There are a few best practices such as a “graceful failure” at the very beginning (L193): if not all the critical inputs are provided, the function returns its own instructions (the text from line 176-189).

The Current document (it could be an empty document) is stored to avoid Dynamo for Civil 3D complaining about the absence of a document at the end of the function, so before leaving it we just need to remember to restore the current document.

2 Likes