(VLE-ENTGETOLD D ENT) error raised - but the lisp works

aridzv
edited August 2023 in LISP Codes
Hi.
I have a lisp that convert line and polylines from one layer to another.
the lisp work ok but raise this error (gost error?..):

; ----- LISP : Call Stack -----
; [0]...C:PIPECONVERT_IRRI_UPDATE1 <<--
;
; ----- Error around expression -----
; (VLE-ENTGETOLD D ENT)

what is the reason for the error?
I've seen this topic:
https://forum.bricsys.com/discussion/38316/infrequent-errors-around-the-repeat-function

but it didn't help...
I've attached the lisp and a sample file.

thanks,
aridzv

Comments

  • up...
    anyone?...
  • Hello aridzv,
    The SSNAMEX function returns a list entry with negative index and without entity. This cannot be evaluated in the FOREACH loop and the error occurs.

    But if you use a REPEAT loop, then only the selected objects are passed through, runtime variable i is incremented.
    To change the layer of the object you can use the ENTMOD function, then you don't have to delete the object and create it again.

    Here's a sample:
    (if (setq ss (ssget '((0 . "LINE,LWPOLYLINE") (8 . "MAINLINE_PIPES,ZONE_PIPES,SPRAYLINES"))))
      (progn
        (setq n 0)
        (repeat (sslength ss)
          (setq eData (entget(ssname aws n)))
          (if (setq f (assoc (cdr(assoc 62 eData))DataList))
            (entmod (subst (cons 8 (cadr f))
                           (assoc 8 eData)
                           eData)))
          (setq n (+ n 1))
          )
        )
      )
    Best regards
    Jörn
  • Hi @JoernBosse and thanks for the reply!!
    the lisp run good,
    but for some reason ignore SPRAYLINES layer even after I explode those polylinens to lines...
    I couldn't find why.

    thanks,
    aridzv
  • In my example there is a typo in line 4:
    (setq eData (entget(ssname ss n)))
    instead of
    (setq eData (entget(ssname aws n)))

    But this is probably not your problem.

    In the example drawing all polylines on the layer "SPRAYLINES" have the color 24.
    Can it be that in your current drawing a color is assigned which is not contained in the DataList, maybe also ByLayer??? Then nothing can happen:
    => (if (setq f (assoc (cdr(assoc 62 eData))DataList))

    best regards
    Jörn