;;************************* { ADD BLOCK PROPERTIES } ****************************;;
;; ;;
;; ------------------ Designed & Created by Satish Rajdev ------------------ ;;
;; ;;
;; ------------------ Command to Invoke = "crl" ------------------ ;;
;; ;;
;; This program as written by Satish colors ONLY the roller and sensor lines ;;
;;********************************************************************************************;;
(defun c:CRVCLR2 (/ setz addprop mid getconn sortlist
removedup cmd nm bks bkl i bk
a b c d e e1 e2 e3
)
(vl-load-com)
;;********************************************************************************************;;
;;**************************************** UTILITIES ****************************************;;
;;********************************************************************************************;;
(defun *error* (msg)
(if (not
(wcmatch (strcase msg t) "*break,*cancel*,*exit*")
)
(progn
(princ "")
(setvar 'nomutt nm)
(setvar 'cmdecho cmd)
(vla-endundomark
(vla-get-activedocument (vlax-get-acad-object))
)
)
)
(princ)
)
;;set error trapping here
(defun setz (pnt)
(list (car pnt) (cadr pnt))
;;remove elevation from the start or end point
)
(defun addprop (obj layer)
(vla-put-color obj 256)
;;put color to bylayer
(vla-put-layer obj layer)
;;put in the layer specifed
)
(defun removedup (l)
(if l
(cons (car l) (removedup (vl-remove (car l) (cdr l))))
;;removing duplicate element from the list
)
)
;;********************************************************************************************;;
;;************************************** MAIN PROGRAM ***************************************;;
;;********************************************************************************************;;
(if (setq bks (ssget '((0 . "insert"))))
;;select block on screen
(progn
(vla-startundomark
(vla-get-activedocument (vlax-get-acad-object))
)
;;setting the undo mark
(setq cmd (getvar 'cmdecho)
nm (getvar 'nomutt)
)
(setvar 'cmdecho 0)
;;hiding command window
(setvar 'nomutt 1)
;;hiding other command details
(mapcar '(lambda (x y)
(if (not (tblsearch "layer" x))
;verifies layer are present or not
(entmakex (list
'(0 . "layer")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 2 x)
(cons 70 0)
(cons 62 y)
(cons 6 "Continuous")
)
)
)
;;creating layer
)
(list "HILMOT-ROLLERS"
"HILMOT-FRAMES"
"HILMOT-MDR"
"HILMOT-SENSORS"
"HILMOT-DRIVE CARDS"
"HILMOT-ARROWS"
)
;;layer list
(list 8 4 3 1 5 4)
;;color code for the layers
)
(repeat (setq i (sslength bks))
;;setting the repeat count
(setq bkl
(cons
(cdr (assoc 2 (entget (ssname bks (setq i (1- i))))))
bkl
)
)
;;getting the selected block list
)
(setq bkl (removedup bkl))
;;removing duplicate names of block
(foreach bk bkl
;;running code for every block
(setq c nil
d nil
ar nil
)
(command "-bedit" bk)
;;opening block editor
(if (setq a (ssget "_x" '((0 . "spline,ellipse,*polyline"))))
;;selecting all splines, plines and ellipsi inside block in block editor
(progn
(repeat (setq i (sslength a))
(setq
b (vlax-ename->vla-object (ssname a (setq i (1- i))))
)
(cond
((and
(not (vlax-curve-isclosed b))
(< (vla-get-length b) 2.5)
)
;;the object is not closed and has length less than 2.5"
(addprop b "HILMOT-SENSORS")
;; then add to this layer
)
((and
(vlax-curve-isclosed b)
(> (vla-get-area b) 10)
)
;;the object is closed and has area greater than 10"
(addprop b "HILMOT-FRAMES")
;; then add to this layer
)
(T
;;the object is an ellipse with spec'd start and end angles
(addprop b "HILMOT-MDR")
;; then add to this layer
)
)
)
);; progn
(princ "\nTHIS IS A SPECIAL TEST MESSAGE. Nothing changed.") ;optional else clause
);; if
(vl-cmdf "_.bclose" "_sav")
;;closing block editor
(initcommandversion)
)
;; foreach
(setvar 'nomutt nm)
(setvar 'cmdecho cmd)
;;restoring the variables again
(vla-endundomark
(vla-get-activedocument (vlax-get-acad-object))
)
;;ending the undo mark
)
;; progn
)
;; if
(princ)
)
(vl-load-com)
(princ)
(princ
(strcat
"\n:: Add Block Properties.lsp ::"
"\n:: Created by Satish Rajdev | "
(menucmd "M=$(edtime,$(getvar,date),DDDD\",\" D MONTH YYYY)"
)
" ::"
"\n:: Type \"crl\" to Invoke ::"
)
)
(princ)