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 expression_re.gh (8.4 KB)
I was thinking of replacing text --> sin( --> sin(rad(, however then the double closing )) is missing.
Any suggestions?
Thanks
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
rodwyll
(robin_gdwl)
October 11, 2020, 10:45am
4
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 02.gh (10.0 KB)
1 Like
Try this
math_exp__re.gh (12.6 KB)
1 Like
You can also evaluate your expressions directly using GHPython, like so:
201011_EvaluateExpression_GHPython_00.gh (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.
2 Likes
If there is a way to change angle unit like system Unit will be better