Convert sin(30) --> sin(rad(30))

Hi Question,

There is a list with items which contains sin,cos,tan functions. whereby the angle are written in degrees (not radians).

Question, I would like to automatically ‘rewrite’ the angles into radians.

2020-10-10 Solve all items with mathematical (8.4 KB)

I was thinking of replacing text --> sin( --> sin(rad(, however then the double closing )) is missing.

Any suggestions?

Thanks :slight_smile: (4.8 KB)

Hi Thanks,

yes it does work in this case :).

Unfortunately there are also items which contain () symbols but dont have a sin in it.
For instance:
2*(8+2) --> 20

In this case the latter ) will be wrongly 'translated into )).

Any suggestions?

Thanks again :slight_smile:

can be done with regex in python.
I am new to regex so this is probably not the best way to do it but it works for the use case you presented.

Let me know if you need further explanation.

SinCosTan to Rad (10.0 KB)

1 Like

Try this (12.6 KB)

1 Like

You can also evaluate your expressions directly using GHPython, like so: (4.2 KB)

I’m importing the radians() function here with an alias that matches your expressions. So if there are more cases, you might need to add more of these import statements.


If there is a way to change angle unit like system Unit will be better