Automatic dimension a plan

Does anyone have any ideas how to dimension the plan by selecting the relevant objects automatically as the link shown below?

Hey Annie, did you find something about the script, i was trying to make simular, but im strugling,
can you give me contact for you ?