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

    Anne Brown Guest

    Alfonso -

    You probably will get an answer here in VBA but you might want to
    repost or look into the discussion group supporting
    Customization/Lisp.

    The Customimzation discussion group can be found on the NNTP
    discussion group reader at
    news://discussion.autodesk.com/autodesk.autocad.customization

    You may also access the Customization discussion group via the
    HTTP web-based forums at
    http://discussion.autodesk.com/forum.jspa?forumID=130
     
    Anne Brown, Jan 15, 2004
    #2
  3. Alfonso-R

    Bill Wright Guest

    It looks like your program is erroring out @ this line:
    (setq DST (* SF (* (strlen EL) 0.10)))

    It would seem that your trying to calculate a variable "SF" that has not been
    set to anything (ie. nil) this may be causing the "error: bad argument type:
    numberp: nil".

    Bill
     
    Bill Wright, Jan 15, 2004
    #3
  4. Good catch! SF is typically scale factor so:

    (setq SF (getvar"DIMSCALE"))
    ___________________________
    Mike Tuersley
    AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Jan 15, 2004
    #4
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.