Paintable Canvas - Polar to Cartesian conversion

Project description:
Operator enters a length and bend angle into a table. This data modifies the dimensions of a line in the paintable canvas. I’ve got the paintable canvas working using cartesian corordinates, but I can’t find an easy way to convert the polar co-ordinates to cartesian.

I’ve only been using Ignition a few days, and I’ve got no scritping experience so I’m probably writing some quite inefficient code and making newbie mistakes, but is there a tidy way to achieve this?

Current plan is to convert the angle to radians, then use trig functions to get X & Y distances, but I can’t seem to get the syntax right and keep getting errors. I noticed that these functions are listed as Expression fucntions in them manual, does this mean they can’t be used in the Script Editor of the Event Handler?

Alternatively, I notice that the Python cMath module has some polar conversion functions, are these an option?

Also, how do I set an editable cell in a table to overwrite?

I think the best way would be to use the python math module and it’s associated trig functions. I do something similar where I start with cartesian coodinates, and then get the hypotenuse so I know how to set the rotation angle to draw angled text. I’m not sure how much of the math module is available in the IA version of jython, but I know all of the trig functions work, i.e. hyp=math.hypot(3,4).

If you post what you’ve tried so far, we’ll get it sorted out.

I’ve got the trig functions working, but math.toRadians or math.toradians gives an AttributeError: class ‘org.python.modules.math’ has no attribute ‘toradians’. I’ve got it working using pi/180, so it’s not a problem, just seems a bit untidy.

I’ve still got a lot to learn about scripting syntax, haven’t done any programming aside from ladder logic.

Still got the problem with setting a cell in a table to overwrite, I know the option should be there, but I can’t find it.

I don’t know too much about Jython/Python but try rad=math.radians(deg);

You can use Java:from java.lang import Math Math.toRadians(value)

that’s fixed the problem with the toRadians function not working, looks like I’ve got a long road ahead getting my head around java scripting.

Any advice on setting an editable cell in a table to overwrite?

Do you mean you want it to select all on focus or actually act like the old overwrite editing mode. (vs insert editing mode). If the latter - there currently isn’t a way to do this.