Jump to content

Recommended Posts

Posted

Hello,

 

I have a problem with a lisp routine used by my company. I am new to autocad/lisps and am just beginning to learn it so was wondering if someone could help me out;

 

-------

 

(defun C:CX (/ eprLayFilt lstTemp lstFilters enaFilter)

(setvar "cmdecho" 0)

(command "_.undo" "be")

(setvar "tilemode" 1)

(command "zoom" "e")

(command ".LAYER" "A" "S" "ORIGINAL" ""

"" "C" "8" "*" "A" "S" "PRINT"

"" "" ""

)

(command "graphscr")

(command ".LAYER" "U" "*" "")

(zflatten)

(setq i -1)

(repeat

(sslength (setq ss (ssget "x" '((-4 . "/=") (62 . 256)))))

(entmod (subst '(62 . 256) (assoc 62 (setq elist (entget (ssname ss (setq i (1+ i)))))) elist))

)

(command ".LAYER" "A" "R" "ORIGINAL" "" "" "")

(vl-load-com)

(vlax-for ps (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))) (vla-delete ps))

(setq eprLayFilt (entget (cdr (assoc 360 (entget (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "LAYER" "0"))))))))))))

(foreach lstTemp eprLayFilt

(if (= (car lstTemp) 360)

(progn (princ lstTemp)

(setq lstFilters (append lstFilters (list (cdr lstTemp))))

)

)

)

(if lstFilters

(foreach enaFilter lstFilters (entdel enaFilter))

)

(setvar "indexctl" 3)

(repeat 3 (command "purge" "a" "*" "n"))

(command "audit" "y")

(command "_.undo" "e")

(setvar "cmdecho" 1)

(princ)

)

 

-----

 

Sometimes it returns an error:

error: bad argument type: lselsetp nil

 

thanks

Posted

That error means that your selection set is nil, try this for a quick fix:

 

(defun C:CX  (/ eprLayFilt lstTemp lstFilters enaFilter)
 (setvar "cmdecho" 0)
 (command "_.undo" "be")
 (setvar "tilemode" 1)
 (command "zoom" "e")
 (command ".LAYER" "A" "S" "ORIGINAL" "" "" "C" "8" "*" "A" "S" "PRINT" "" "" "")
 (command "graphscr")
 (command ".LAYER" "U" "*" "")
 (zflatten)
 (setq i -1)
 (if (setq ss (ssget "x" '((-4 . "/=") (62 . 256))))
   (progn
     (repeat
   (sslength ss)
    (entmod (subst '(62 . 256) (assoc 62 (setq elist (entget (ssname ss (setq i (1+ i)))))) elist))
    )
     (command ".LAYER" "A" "R" "ORIGINAL" "" "" "")
     (vl-load-com)
     (vlax-for    ps  (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object)))
   (vla-delete ps))
     (setq eprLayFilt
        (entget
          (cdr (assoc 360
              (entget (cdr (assoc 360 (entget (cdr (assoc 330 (entget (tblobjname "LAYER" "0"))))))))))))
     (foreach lstTemp    eprLayFilt
   (if (= (car lstTemp) 360)
     (progn (princ lstTemp)
        (setq lstFilters (append lstFilters (list (cdr lstTemp))))
        )
     )
   )
     (if lstFilters
   (foreach enaFilter lstFilters (entdel enaFilter))
   )
     (setvar "indexctl" 3)
     (repeat 3 (command "purge" "a" "*" "n"))
     (command "audit" "y")
     (command "_.undo" "e")
     (setvar "cmdecho" 1))
   (princ "\n<!> Nothing Found <!>"))
 (princ)
 )

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...