Getpoint z or setpoint z

I write this code but not working. I want use pickpoint z or entered z coordinate at the same time. but first want getpoint I entred number not working. what can I do for this problem. if c# is my solution ı can write code in the c#.

a = rs.getpoint(True, True,“z crd”) or int()

Hi @emrahoksak,

In C# and python, it is not possible to get two different inputs of different types. Normally you would ask for a user input and check it is the correct type. So in this you might use instead, check if the user has selected a point and get the Z co-ordinate from that, if the user has not selected a point, then request user input. Check if the input is 3 number (a point) or a single number, the Z-co-ord.

If you are willing to delve into rhinocommon, I think this can be done with Rhino.Input.Custom.GetPoint() with an option:

import Rhino as R
import rhinoscriptsyntax as rs
import scriptcontext as sc

# make a GetPoint object
getter = R.Input.Custom.GetPoint()

# make an OptionInteger object
# it is needed to allow the getter to also get a number
int_option = R.Input.Custom.OptionInteger(2)

# add the OptionInteger to the getter
getter.AddOptionInteger('zOption', int_option)

# tell the getter to run

# now the getter should have something, but first...
# setup default case for printing the result
msg = 'User did not select a point or enter a number...'
value = ''

# now test the getter result type
# it should match one of the Rhino.Input.GetResult enumeration types

# we are interested in the 'Option' type if the user entered a number
if getter.Result() == R.Input.GetResult.Option:
    # change print result variables accordingly..
    value = int_option.CurrentValue
    msg = 'User entered a number: '

# or the 'Point' type, if a point was selected
elif getter.Result() == R.Input.GetResult.Point:
    value = getter.Point()
    msg = 'User selected a point: '

# print the result
print msg + str(value)

hi @nathancoatney , @christopher.ho thans for reply
@nathancoatney your code is works perfectly .thank you for your help.
I asking one more thing. how can print z coordinate when I pickpoint.

User selected a point: <built-in method Point of GetPoint object at 0x0000000000000045>

I think the point refers to the following:

So you should use:


thank ı trying

Oops, I forgot a parenthesis:

I updated the code above.

Now value should be a Rhino.Geometry.Point3d so to get the Z coord it is just:


Thank you so much about the code that you gave. It’s working perfectly.