+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Full Member
    Computer Details
    TheyCallMeJohn's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell Precision M6800
    CPU:
    Intel Core i7-4930MX @ 3.00 GHz
    RAM:
    32.0 GB
    Graphics:
    NVIDIA Quadro FX 5800
    Using
    AutoCAD 2015
    Join Date
    Apr 2010
    Location
    Huntington Beach, CA
    Posts
    80

    Default 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"))
    	(vl-load-com)
    	(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
    	(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. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,360

    Default

    Without looking over all of your code:
    Code:
    (setq NEWPT1 (LIST (CAR USRP1) (CADR USRP1) (+ (CADDR USRP3) TRAP_Z_OFF)))
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,879

    Default

    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
    A man who never made mistakes never made anything

Similar Threads

  1. All You Need is Math
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 13th Feb 2015, 04:50 pm
  2. modify point style or library
    By guigol in forum AutoCAD Beginners' Area
    Replies: 10
    Last Post: 2nd Oct 2012, 05:36 pm
  3. cad is like math
    By michaeloureiro in forum AutoCAD Drawing Management & Output
    Replies: 15
    Last Post: 18th Aug 2011, 12:02 am
  4. Want to modify a simple dimension suffix modify visuallisp
    By CADkitt in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 9th Sep 2010, 01:52 pm
  5. Block insertion point modify?
    By manirpg in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 31st Jul 2010, 06:51 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts