I am making an add-on where I am starting a Drawing Tool from code. I want to start the drawing tool with a specific template. I know there is no supported way to do this, but I came up with what I thought was a pretty good work around.
I did a test with a Drawing Tool that had no Default.xml template, but did have other templates created via NT8s templating functionality by an end user.
I started the drawing tool and it just used NT8s default template as expected.
While NT is still running, I copied the specific template I wanted the Drawing Tool to start with to Default.xml in the Drawing Tools template dir, and then started the drawing tool. It started and I did a drawing on the chart and the drawing had the template I wanted.
I then deleted the Default.xml I had created and started the drawing tool again, and it just used the default NT template for that tool. Perfect.
Based on this I thought fantastic, I have a solution. So I then designed an add-on around this functionality. As I was building it I thought to take this further I wanted to check to see if there was a User defined Default.xml, and back that up first, and then restore it after the drawing was completed.
I did this, but I found that after the first time the Drawing Tool starts with a Default.xml in the Drawing Tools template dir, it caches that copy of the Default.xml for the duration of that NT8 application session. You can delete the Default.xml, and then create a new Default.xml in its place with a different template XML in its content, but when you start the tool again, it still loads the cached Default.xml, not the new content from the file system.
With NT8 still running I renamed the Template dir and then started the tool and it did revert back to the NT8 default, but when I renamed the Template dir back again and started the tool again, it still used the cached Default, instead of the Default.xml in the template dir.
So NT8 detects if there is a Default.xml in the template dir, but if it has previously cached the file, it never loads it from the file system again for the duration of that application session, even if the timestamp and content of the file have changed.
I can't seem to find a way around this. Is there any way I can programmaticly clear the cached Default template or force NT to load it from the file system again?
Thanks for your time,
codeOwl
Comment