Lisp Routine Help Please!!

Discussion in 'AutoCAD' started by Alfonso-R, Jan 15, 2004.

  1. Alfonso-R

    Alfonso-R Guest

    The routine below is for labelling contours.
    I have tried to run the program, but it keeps
    coming up with an error after the "digitize a point
    to the right" command. AutoCAD returns this message
    "error: bad argument type: numberp: nil". Also,
    is it possible to modify the program to be able to
    automatically pick the z value of the pline in stead
    of manually entering the text?? Any help would be greatly appreciated!!!

    Al

    ;*******CONTOUR ELEVATION LABELING ROUTINE******
    ; ENT - Contour line being labeled
    ; IPT - Left insertion point of label
    ; ANG - Insertion angle of label
    ; DST - Distance to break contour line
    ; EL - Elevation of selected contour
    ;-----------------------------------------------
    (defun C:CTEXT (/ ENT IPT ANG DST EL)
    ;-----INITILAIZE PROGRAM----
    (setq VARLST (list "OSMODE" "CLAYER" "TEXTSTYLE"))
    (start)
    (setvar "OSMODE" 512)
    (setvar "FLATLAND" 0)
    (setq ENT (entsel "\nDigitize the left insertion point: ")
    IPT (cadr ENT)
    ENT (car ENT))
    (setvar "OSMODE" 0)
    ;-----GET ANGLE & ELEVATION---------
    (setq ANG (getangle IPT "\nDigitize a point to the right: ")
    EL (rtos (cadddr (assoc 10 (entget ENT))) 2 0))
    ;----BREAK THE LINE----------------
    (setq DST (* SF (* (strlen EL) 0.10)))
    (command "break" ENT IPT (polar IPT ANG DST))
    ;-----------------INSERT THE TEXT------------------------
    (command "layer" "m" "TXT100" "")
    (command "text" "s" "VLEROY" "m" (polar IPT ANG (/ DST 2))
    (* SF 0.1) (angtos ANG 0 4) EL)
    (done)
    )
     
    Alfonso-R, Jan 15, 2004
    #1
  2. Alfonso-R

    ECCAD Guest

    In below sequence: The variable 'SF' is not being set.
    ----------------------------
    (setq ENT (entsel "\nDigitize the left insertion point: ")
    IPT (cadr ENT)
    ENT (car ENT))
    (setvar "OSMODE" 0)
    ;-----GET ANGLE & ELEVATION---------
    (setq ANG (getangle IPT "\nDigitize a point to the right: ")
    EL (rtos (cadddr (assoc 10 (entget ENT))) 2 0))
    ;----BREAK THE LINE----------------
    (setq DST (* SF (* (strlen EL) 0.10)))
    -------------------------

    You may want to add:
    (setq SF (getvar "DIMSCALE"))
    Just after:
    (setvar "OSMODE" 0)

    Bob
     
    ECCAD, Jan 15, 2004
    #2
  3. Alfonso-R

    Paul Turvill Guest

    What kind of object are you selecting at the "digitize a point to the right"
    prompt?
    ___
     
    Paul Turvill, Jan 15, 2004
    #3
  4. Alfonso-R

    Jim Claypool Guest

    I don't know what (start) does, but SF is not set. That is causing the
    error.
    This version will pick the z value from the first point selected.

    (defun C:CTEXT (/ ENT IPT ANG DST EL)
    ;-----INITILAIZE PROGRAM----
    (setq VARLST (list "OSMODE" "CLAYER" "TEXTSTYLE"))
    ;(start)
    (setvar "OSMODE" 512)
    (setvar "FLATLAND" 0)
    ;(setq ENT (entsel "\nDigitize the left insertion point: "))
    ;(setq IPT (cadr ENT))
    (setq
    IPT (getpoint "\nDigitize the left insertion point: ")
    ENT (car (nentselp IPT))
    )
    (setvar "OSMODE" 0)
    ;-----GET ANGLE & ELEVATION---------
    ;(setq SPT (getpoint "\nDigitize a point to the right: "))
    (setq ANG (getangle IPT "\nDigitize a point to the right: "))
    (setq EL (rtos (caddr IPT) 2 0))
    ;----BREAK THE LINE----------------
    (setq DST (* SF (* (strlen EL) 0.10)))
    (command "break" ENT IPT (polar IPT ANG DST))
    ;-----------------INSERT THE TEXT------------------------
    (command "layer" "m" "TXT100" "")
    (command "text" "s" "VLEROY" "m" (polar IPT ANG (/ DST 2)) (* SF 0.1)
    (angtos ANG 0 4) EL)
    ;(done)
    )
     
    Jim Claypool, Jan 15, 2004
    #4
  5. Alfonso-R

    Alfonso-R Guest

    I am selecting a point along the same contour.
     
    Alfonso-R, Jan 15, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.