Python is not defined problem

import rhinoscriptsyntax as rs

def box3pt(p1, p2 ,p4, z2):

pt0 = p1
pt1 = rs.coerce3dpoint([p2[0], p1[1], p1[2]])
pt2 = rs.coerce3dpoint([p2[0], p2[1], p1[2]])
pt3 = rs.coerce3dpoint([p1[0], p2[1], p1[2]])
pt4 = rs.coerce3dpoint([p1[0], p1[1], p4[2]])
pt5 = rs.coerce3dpoint([p2[0], p1[1], p4[2]])
pt6 = rs.coerce3dpoint([p2[0], p2[1], p4[2]])
pt7 = rs.coerce3dpoint([p1[0], p2[1], p4[2]])

rs.AddBox([pt0, pt1, pt2, pt3, pt4, pt5, pt6, pt7])

def zkayit():

zk = open("zk.txt","w")
zk.write(p4)
zk.close()

ana = open ('zk.txt','r')
z2 = ana.readline()
z2 = z2.rstrip('\n')
z2 = int(z2)

z2 = ana.readline()
z2 = z2.rstrip('\n')
print(type(z2))

zkayit()

def degerlerim():

p1 = rs.GetPoint('ilk nokta')
if not p1: return
p2 = rs.GetPoint('ilk nokta')
if not p2: return
p3 = rs.GetPoint('ilk nokta')
if not p3:
    a = 0
    b = 0
    c = z2
    p3 = rs.AddPoint(a, b, c)
p4 = p3
box3pt(p1, p2, p4)

degerlerim(z2)

hi ı get this problem. I don’t know how to fix that problem. When I run the program and give values It says “z2 is not defined”. My regards

p3 = rs.AddPoint(a, b, 100)
p4 = int(p3[2])

How can change the z coordinates of the points to integer?
When I use this code I get this error;

Message: ‘Guid’ object is not subscriptable

Hi @mak4203,

This is a bit simpler:

import Rhino
import scriptcontext as sc

rc, box = Rhino.Input.RhinoGet.GetBox();
if rc == Rhino.Commands.Result.Success:
    sc.doc.Objects.AddBox(box)
    sc.doc.Views.Redraw();

– Dale

Hello,

Does this work p4 = int( rs.PointCoordinates(p3)[2]) ?

Hello,

    z2 = int(z2)

    z2 = ana.readline()
    z2 = z2.rstrip('\n')
    print(type(z2))
    return z2

z2=zkayit()

hello
this code Does this work p4 = int( rs.PointCoordinates(p3)[2]) ? no nat work

thanks

dale I have a cordinate in txt file way you is not simpler for me I cant one by one draw in rhino

p3 = rs.CreatePoint(...) ?