Template updates in designer

I’ve been working on a few templates that basically need to run an initialization function to get all its data and look right (example, a radarchart that gets its axis values based on a single tag path, a moving analog indicator that gets all of its configuration from variable paths that are found via script, and these usually are in a template canvas that places based on its own size). I can put the script on the Property Change event when componentRunning = Ttrue, however this doesn’t work in the designer, not even in preview mode. I can think of a couple workarounds for the designer mode (like a timer component, or maybe an internal component bound to the system time tag and an propchanged attached to that, etc) but as far as I can tell there is nothing that I can do to run this while in the designer, not in preview mode. This is mainly for the parts that need to change their size based on the overall template size. As it is they all start at the size the original template definition is at which isn’t accurate.

So - anyone know of anything that can trigger some sort of script in a template while preview mode is off?

Use runScript() to call a custom component method, and use a zero poll interval. It’ll run once when the bindings are set up.

Very nice and very simple! However it doesn’t seem to have access to the shared or project script libraries. I’ve tried to import them too with no luck (no shared/project module exists, it says). The function I have there is a fairly small one so I’ll move it to a custom component function for now but I’d love to be able to call project or shared scripts here if needed.

Edit: Looks like it has selective issues with system packages. Like a system.dataset.toPyDataSet works fine, but system.util.getSystemFlags() doesn’t work, no attribuite “getSystemFlags”

That’s odd. Try it with objectScript instead of runScript, if you don’t mind.

I’d like to, but I haven’t been able to convince the people who make those decisions to install it yet. Trying, but not there just yet.

So just to follow up a bit, it looks like some uses of System.X.Y are fine, others aren’t - does anyone know why this happens? When it works, it works great and is exactly what I was looking for! But it isn’t working 100% when needed because of these errors.

Can you post your code? I have bound template properties with expressions like this and it works.

runscript("project.math.group", 0, 123456)

I also tried the following, and I didn’t get any errors.

runscript("system.util.getSystemFlags", 0)