Degrees input

In python how to add degrees in input?


I think you just need to add a Boolean input and convert in the script…

Only possible via code:


Yes i did that but i prefer the other option like in regular components

Conversion is not the problem we can convert between degrees/radians with math or cmath.
I need this small degrees icon like in math components

I find this but still search to find a way how to use it

import Grasshopper

print Grasshopper.Kernel.Parameters.Param_Number.AngleParameter

I don’t think Python uses a NumberParameter as an input, so you cannot set the angle option.

Sadly , i thought this will be a step for a solution


But why? All that input component does is convert your radian input into degrees. You can do that yourself straight away in Python, so it doesn’t matter whether you input as degrees or radians.

No the components don’t convert anything , the user choose degrees or radians.
For example, how the component know if 3 is degrees or radians?

The icon you refer to, when that is selected, it converts from radians to degrees. You have to have something telling the user to use radians or degrees. How would any programming element know whether a user is using radians or degrees?

I never ask for this because it is impossible, and i need this option for a component which have all these Trigonometric functions

If you want the user to choose radians or degrees, then just add a value list component to choose between radians & degrees:

import rhinoscriptsyntax as rs
import math

if y == 0:
    num = [i for i in x]
if y == 1:
    num = [i/180*math.pi for i in x]
a = [math.sin(i) for i in num]

There are other option , like boolean but something like in the regular component will be better, no need to use another input

Actually i use another solution

Degrees always the unit by default and with boolean it change

Solved , the solution already available

p = Grasshopper.Kernel.Parameters.Param_Number()
p.AngleParameter = True
p.UseDegrees = True