PDA

View Full Version : Color Filter


youngsoo
2007-10-19, 08:37 AM
Please modify.

(defun table-list(name / dxf return)
(while (setq dxf(tblnext name(not dxf)))
(setq return(cons(cdr(assoc 2 dxf))return))
)
(reverse return)
;;(table-list"LTYPE")
;;(table-list"VIEW")
;;(table-list"STYLE")
;;(table-list"BLOCK")
;;(table-list"UCS")
;;(table-list"APPID")
;;(table-list"DIMSTYLE")
;;(table-list"VPORT")
;(table-list"LAYER")
)

;;;;-------------------------------------------

(defun off-layer-list(/ dxf return )
(while (setq dxf(tblnext"layer"(not dxf)))
(if (<(cdr(assoc 62 dxf))0)
(setq return(cons(cdr(assoc 2 dxf))return))
)
)
(reverse return)

)

;;;-------------------------------------------------

(defun frozen-layer-list(/ dxf return)
(while (setq dxf(tblnext"layer"(not dxf)))
(if (=(logand(cdr(assoc 70 dxf))1)1)
(setq return(cons(cdr(assoc 2 dxf))return))
)
)
(reverse return)

)
;;-------------------------------------------------

(defun locked-layer-list(/ dxf return)
(while (setq dxf(tblnext"layer"(not dxf)))
(if (=(logand(cdr(assoc 70 dxf))4)4)
(setq return(cons(cdr(assoc 2 dxf))return))
)
)
(reverse return)

)

;;-------------------------------------------------

(defun offfrozenlockedlayerlist()

(if(or (off-layer-list) (frozen-layer-list) (locked-layer-list) )

(progn


(setq aa (off-layer-list))
(setq bb (frozen-layer-list))
(setq cc (locked-layer-list))


(setq xx (car aa))
(setq yy (car bb))
(setq zz (car cc))



(alert "\noff=>" xx
" \n frozen=>" yy
"\n locked " zz)


);progn end


(progn
(prompt ) (princ (off-layer-list) )
(prompt " frozen=>") (princ (frozen-layer-list) )
(prompt " locked=>") (princ (locked-layer-list) )
);progn end

);if end
)

;;;------------------------------------------------------------------------------------------------------------

(defun change-entity-color-as-show (/ adoc selset layer)
(vl-load-com)
(vla-startundomark
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
) ;_ end of vla-startundomark
(if (setq selset (ssget "X"))
(foreach item (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex selset)))
) ;_ end of mapcar
(setq layer (vla-item (vla-get-layers adoc) (vla-get-layer item)))
(vla-put-color item (vla-get-color layer))
(if (= (strcase (vla-get-linetype item)) "BYLAYER")
(vla-put-linetype item (vla-get-linetype layer))
) ;_ end of if
) ;_ end of foreach
) ;_ end of if
(vla-endundomark adoc)
(princ)
) ;_ end of defun


;;;--------------------------------------------------------------------------------------------------

(defun c:colorFilter (/ entity entityname entityList colorList colorNumber ss) ;main

(offfrozenlockedlayerlist)

(change-entity-color-as-show) ;;

(setq entityname (car (entsel "\nSelect filtering color : "))) ;entsel - This function prompts for the user to pick one entity.


(redraw entityname 3)

(setq entityList (entget entityname))
(setq colorList (assoc 62 entityList))
(setq colorNumber (cdr colorList))


(prompt "\"")(princ colorNumber ) (prompt (strcat "\"" "******* "))
;;;returns two strings in variable a & b as one.

(prompt "\nSelect objects or < all >: ")

(if (not (setq ss (ssget "_:S" (list (cons 62 colorNumber)) )))
(setq ss (ssget "_X" (list (cons 62 colorNumber) ) ))

);;

(redraw entityname 4)
(sssetfirst nil ss)

(princ)
)

rkmcswain
2007-10-23, 02:57 PM
Please modify? Need a little more than that.

CAB2k
2007-10-23, 05:12 PM
Maybe this will give you some ideas for your routine.

youngsoo
2007-10-25, 05:44 AM
Please solve the problem of (alert "\noff=>" xx " \nfrozen=>" yy "\nlocked=>" zz)

rkmcswain
2007-10-25, 02:19 PM
Please solve the problem of (alert "\noff=>" xx " \nfrozen=>" yy "\nlocked=>" zz)

How about
(alert (strcat "\noff=>" xx " \nfrozen=>" yy "\nlocked=>" zz))

youngsoo
2007-10-29, 09:52 AM
Please solve the problem of ;;(alert (off-layer-list) (frozen-layer-list) (locked-layer-list))


(defun table-list(name / dxf return)
(while (setq dxf(tblnext name(not dxf)))
(setq return(cons(cdr(assoc 2 dxf))return))
)
(reverse return)
;;(table-list"LTYPE")
;;(table-list"VIEW")
;;(table-list"STYLE")
;;(table-list"BLOCK")
;;(table-list"UCS")
;;(table-list"APPID")
;;(table-list"DIMSTYLE")
;;(table-list"VPORT")
;(table-list"LAYER")
)

;;;;-------------------------------------------

(defun off-layer-list(/ dxf return )
(while (setq dxf(tblnext"layer"(not dxf)))
(if (<(cdr(assoc 62 dxf))0)
(setq return(cons(cdr(assoc 2 dxf))return))
)
)
(reverse return)

)

;;;-------------------------------------------------

(defun frozen-layer-list(/ dxf return)
(while (setq dxf(tblnext"layer"(not dxf)))
(if (=(logand(cdr(assoc 70 dxf))1)1)
(setq return(cons(cdr(assoc 2 dxf))return))
)
)
(reverse return)

)
;;-------------------------------------------------

(defun locked-layer-list(/ dxf return)
(while (setq dxf(tblnext"layer"(not dxf)))
(if (=(logand(cdr(assoc 70 dxf))4)4)
(setq return(cons(cdr(assoc 2 dxf))return))
)
)
(reverse return)

)

;;-------------------------------------------------

(defun offfrozenlockedlayerlist()

(if(or (off-layer-list) (frozen-layer-list) (locked-layer-list) )

;;(alert (off-layer-list) (frozen-layer-list) (locked-layer-list))


(progn
(prompt "\noff=>" ) (princ (off-layer-list) )
(prompt " frozen=>") (princ (frozen-layer-list) )
(prompt " locked=>") (princ (locked-layer-list) )
);progn end

);if end
)

;;;---------------------------------------------------

(offfrozenlockedlayerlist)

(defun c:change-entity-color-as-show (/ adoc selset layer)
(vl-load-com)
(vla-startundomark
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
) ;_ end of vla-startundomark
(if (setq selset (ssget "X"))
(foreach item (mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp (mapcar 'cadr (ssnamex selset)))
) ;_ end of mapcar
(setq layer (vla-item (vla-get-layers adoc) (vla-get-layer item)))
(vla-put-color item (vla-get-color layer))
(if (= (strcase (vla-get-linetype item)) "BYLAYER")
(vla-put-linetype item (vla-get-linetype layer))
) ;_ end of if
) ;_ end of foreach
) ;_ end of if
(vla-endundomark adoc)
(princ)
) ;_ end of defun