You can have a look at this thread, it explain most methods you can use to get/set colors. In this thread you will have more context on how to get the diagram elements. Finally this thread focus more on layout but might also be interesting.
If you need more help let me know.