Jump to content

ssget filter


paulmcz

Recommended Posts

Is there a way to replace the ssget filter like '((62 . 5)) with a variable?

When I set variable occ to (cons 62 5), ssget won't work with it.

 

(setq ss (ssget "X" occ))

 

Here is the routine:

 

(defun c:cch (/ ss a ln ent cc oc occ)
 (setq	a  nil
cc (getint "\n Set new colour [integer]: ")
oc (getint "\n Colour to be changed [integer]: ")
occ (cons 62 oc)
 )
 (if (= (getvar 'tilemode) 0)
   (progn (setvar 'tilemode 1)
   (setq a 2)
   )
 )
 (if (setq ss (ssget "X" occ))
   (command "change" ss "" "p" "c" cc "")
 )
 (setq ln (tblnext "layer" T))
 (while ln
   (setq ent (entget (tblobjname "layer" (cdr (assoc 2 ln))))
  ln  (tblnext "layer")
   )
   (if	(= oc (cdr (assoc 62 ent)))
     (progn
(setq ent (subst (cons 62 cc) occ ent))
(entmod ent)
     )
   )
 )
 
 (if (= a 2)
   (setvar 'tilemode 0)
 )
 (princ)
)

 

Any idea anyone?

 

Thanks.

Link to comment
Share on other sites

(setq occ '((62 . 5)))

 

Or:

 

(setq occ (list (cons 62 5)))

 

Then:

 

(ssget "_X" occ)

 

Alternatively:

 

(setq occ '(62 . 5))

 

Or:

 

(setq occ (cons 62 5))

 

Then:

 

(ssget "_X" (list occ))

Link to comment
Share on other sites

Maybe this will help:

 

(defun c:cch ( / cc co en in ld oc ss )
   (if
       (and
           (princ "\nSelect New Colour: ")
           (princ)
           (setq cc (acad_colordlg 1 nil))
           (princ "\nSelect Colour to be Changed: ")
           (princ)
           (setq oc (acad_colordlg 1 nil))
       )
       (progn
           (if (setq ss (ssget "_X" (list (cons 62 oc))))
               (repeat (setq in (sslength ss))
                   (setq en (entget (ssname ss (setq in (1- in)))))
                   (entmod (subst (cons 62 cc) (assoc 62 en) en))
               )
           )
           (while (setq ld (tblnext "LAYER" (null ld)))
               (if (= oc (abs (cdr (setq co (assoc 62 ld)))))
                   (progn
                       (setq en (entget (tblobjname "LAYER" (cdr (assoc 2 ld)))))
                       (entmod (subst (cons 62 (* cc (if (minusp (cdr co)) -1 1))) co en))
                   )
               )
           )
       )
   )
   (princ)
)

Link to comment
Share on other sites

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...