Help with Troubling LISP

Discussion in 'AutoCAD' started by bellenoit, May 7, 2004.

  1. bellenoit

    bellenoit Guest

    HELP!! this list uses a script file to add a Slot around dimension text...
    Only problem is we can only get it to run on A2k4... A2k5 gets the error: ; error: bad argument type: lselsetp nil

    here is the code...

    (defun c:Iso (/ callents ncallents viewportents nviewportents a n rcallents nrcallents nentdel nstartentdel nendentdel n1)
    (setq callents (ssget "x"))
    (setq ncallents (sslength callents))
    (setq viewportents (ssget "x" '((0 . "Viewport"))))
    (setq nviewportents (sslength viewportents))
    (setq a (ssget '((0 . "Dimension"))))
    (setq n (sslength a))
    (if (> n 1)(exit))(princ)
    (if (< n 1)(exit))(princ)
    (command "copy" a "" "0,0" "0,0")
    (command "explode" "l")
    (command "script" "R:\BBraun CAD Standards\iso.scr")
    (setq rcallents (ssget "x"))
    (setq nrcallents (sslength rcallents))
    (setq nentdel (- nrcallents (1+ ncallents)))
    (setq nstartentdel (1+ nviewportents))
    (setq nendentdel (+ nstartentdel nentdel))
    (setq n1 "w")
    (while n1
    (entdel (ssname rcallents nstartentdel))
    (setq nstartentdel (1+ nstartentdel))
    (if (= nstartentdel nendentdel)
    (setq n1 nil)
    )
    )
    )
     
    bellenoit, May 7, 2004
    #1
  2. bellenoit

    bellenoit Guest

    We have since removed the file path from the script line since it's in our custom paths...

    any ideas...

    Thanks!

    noit
     
    bellenoit, May 7, 2004
    #2
  3. bellenoit

    bob.at Guest

    Hi,

    i dont know much about 2005, but maybe you have there a drawing withaout any viewport. Then viewportents is nil an sslength reports the error. The sam can happen by all other ssget function, ig var callents. So you should always test ob a ssget was sucessfull or not.

    bob.at
     
    bob.at, May 7, 2004
    #3
  4. bellenoit

    CAB2k Guest

    Added some error checking but not sure of the intended flow.

    Code:
    (defun c:Iso (/            callents     ncallents    viewportents
    nviewportents             a            n
    rcallents    nrcallents   nentdel      nstartentdel
    nendentdel   n1
    )
    (if (and ;skip on first nil
    (setq callents (ssget "x"))
    (setq ncallents (sslength callents))
    (setq viewportents (ssget "x" '((0 . "Viewport"))))
    (setq nviewportents (sslength viewportents))
    )
    (progn
    ;;  not sure what is going on here, if there are no dimension
    ;;  objects then a = nil, not 0, so the test (>n 1) ?
    (if ; always test the ss before getting its length
    ;; if a is empty it abort
    (setq a (ssget '((0 . "Dimension"))))
    (progn
    ;;  ?? what is this for?
    ;;(setq n (sslength a))
    ;;(if (> n 1) (exit))
    ;;(princ)
    ;;(if (< n 1) (exit))
    ;;(princ)
    (command "copy" a "" "0,0" "0,0")
    (command "explode" "l")
    (command "script" "R:\BBraun CAD Standards\iso.scr")
    (if (setq rcallents (ssget "x"))
    (progn ; if rcallents empty skip
    (setq nrcallents (sslength rcallents))
    (setq nentdel (- nrcallents (1+ ncallents)))
    (setq nstartentdel (1+ nviewportents))
    (setq nendentdel (+ nstartentdel nentdel))
    (setq n1 "w")
    (while n1
    (entdel (ssname rcallents nstartentdel))
    (setq nstartentdel (1+ nstartentdel))
    (if (= nstartentdel nendentdel)
    (setq n1 nil)
    )
    )
    )
    ) ; endif rcallents empty skip
    )
    ); endif a is empty
    )
    ); endif callents or viewportents is empty
    (princ) ; quiet exit, else change this line to n1
    ;; n1 ; return result
    ); end defun
     
    CAB2k, May 7, 2004
    #4
  5. bellenoit

    zeha Guest

    maybe

    (command "script" "R:\\BBraun CAD Standards\\iso.scr")
    or

    (command "script" "R:/BBraun CAD Standards/iso.scr")
     
    zeha, May 9, 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.