While creating this type of script is "possible". The creation and runtime of script become an issue.
Because the BobCAD scripting engine does not allow the user to highlight entities based on their location in the Drawing area, it is up to the user to figure out what is where. This can be done a multitude of ways, my favorite happens to be the array.
You would need to assign the width, height, minx and miny to arrays for use in condition statements. In order to get that you would need to first generate the code for the entire part and then loop through the code to create the values that would be output.
It can be quite memory intensive when running it on your computer, but would be the only way to accomlish what you are after.