# Modify an X, Y, X Point Using Math

## Recommended Posts

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:

`(setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE `

Here is the full 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.

##### Share on other sites

Without looking over all of your code:

`(setq NEWPT1 (LIST (CAR USRP1) (CADR USRP1) (+ (CADDR USRP3) TRAP_Z_OFF)))`

##### Share on other sites

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

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

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.