# Thread: Modify an X, Y, X Point Using Math

1. ## Modify an X, Y, X Point Using Math

Registered forum members do not see this ad.

Hey Guys,
Its been a awhile since I have done any Autolisp programming and I am stuck...

I am using a conditional statement to generate a number i.e. 1.625 and then I want to add that to the Z elevation of a point but it keep erroring out at this line. I have spent about an hour and half looking back thru resources and haven't been able to find the correct syntax.

This is the line erroring out:

Code:
`(setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE`
Here is the full code.

Code:
```(defun C:droptrap()
(command "UNDO" "BEGIN")
(initerr)
(setvar "lunits" 2)
(setvar "luprec" 4)
(setvar "attreq" 0)
(command "UNDO" "BEGIN")
(setq OLDCMD (GETVAR "CMDECHO"))
(setvar "CMDECHO" 0)
(setq OLDOSMODE (GETVAR "OSMODE"))
(setvar "OSMODE" 0)
(setq OLDORTHOMODE (GETVAR "ORTHOMODE"))
(initget "1 2 3 4")
(setq TRAP_TYPE (getkword "\n Select trapeze type: ([1]:1-5/8x1-5/8, [2]:1-5/8x1-5/8 B2B, [3]1-5/8x13/16, [4]1-5/8x13/16 B2B):  "))
(if (or (= TRAP_TYPE "1")(= TRAP_TYPE "3"))
(progn
(initget "1 2")
(setq FACE_DIR (getkword "\n Trapeze opening up or down?: ([1]:UP [2]:Down):  "))
)
(setq FACE_DIR "1")
)
(cond
((and (= TRAP_TYPE "1")(= FACE_DIR "2"))
(setq TRAP_Z_OFF 1.625))
((and (= TRAP_TYPE "3")(= FACE_DIR "2"))
(setq TRAP_Z_OFF 0.8125))
(T (setq TRAP_Z_OFF 0.0))
)
(setq blockname "TRAP-XDATA-T1_1.625")
(setq USRP1 (GETPOINT "\n Select center point of rod 1: "))
(setq USRP2 (GETPOINT "\n Select center point of rod 2: "))
(setq USRP3 (getpoint "\n Select elevation of attachment point: "))
(setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE
(setq NEWPT2 (APPEND (LIST (CAR USRP2) (CADR USRP2)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE TOO
(setq MIDPT (POLAR NEWPT1 (ANGLE NEWPT1 NEWPT2) (* (DISTANCE NEWPT1 NEWPT2) 0.5)))
(setvar "ORTHOMODE" 1)
(COMMAND "-INSERT" BLOCKNAME MIDPT "1" "1" NEWPT2)
(command "rotate3d" (entlast) "" 2 NEWPT1 NEWPT2 90)
(setvar "OSMODE" OLDOSMODE)
(setvar "CMDECHO" OLDCMD)
(setvar "CLAYER" LAYNAME)
(COMMAND "UNDO" "END")
(PRINC)
)```

The code is unfinished so I am trying to keep it working as I build it.

2. Without looking over all of your code:
Code:
`(setq NEWPT1 (LIST (CAR USRP1) (CADR USRP1) (+ (CADDR USRP3) TRAP_Z_OFF)))`

3. Registered forum members do not see this ad.

Like Lee spotted the missing "A" very quickly another way is you can use

Code:
```(nth 0 pt); X
(nth 1 pt); Y
(nth 2 pt); Z```