Here you are :
(defun c:spiralpl (/ removedup addprop bks cmd nm bkl a b c d e i)
(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)
)
(defun removedup (l)
(if l
(cons (car l) (removedup (vl-remove (car l) (cdr l))))
;; removing duplicate element from the list
)
)
(defun addprop (obj layer)
(vla-put-color obj 256)
;; put color to bylayer
(vla-put-layer obj layer)
;; put in the layer specifed
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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)
;; add layername
(cons 70 0)
(cons 62 y)
;; add color
(cons 6 "Continuous")
)
)
)
;; creating layer
)
(list "HILMOT-ROLLERS"
"HILMOT-SENSORS"
"HILMOT-FRAMES"
"HILMOT-MDR"
)
;; layer list
(list 8 1 4 5 5 3)
;; 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
(command "-bedit" bk)
;; opening block editor
(vla-zoomextents (vlax-get-acad-object))
(setq e nil)
(if (setq a (ssget "_x" '((0 . "*polyline"))))
;; selecting all polylines inside block in block editor
(progn
(repeat (setq i (sslength a))
(setq
b (vlax-ename->vla-object (ssname a (setq i (1- i))))
)
;; getting each polyline object
(cond ;; applying conditions here
((and (eq (vla-get-objectname b) "AcDbPolyline")
;; check object is POLYLINE
(setq c (car (vlax-get b 'coordinates)))
;; Get "X" coordinate of start point
(vl-some '(lambda (x)
(equal c x 1e-4)
)
'(20 30 -26.0633 13.7408)
)
;; Check whether the x coordinate of the polyline start point matches with the list if matches then do this
)
(addprop b "HILMOT-SENSORS")
)
(t (addprop b "HILMOT-ROLLERS"))
;; All rest objects goes to this layer
(print x)
(print c)
)
)
)
)
(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:: Spiral.lsp ::"
"\n:: Based on a program Created by Satish Rajdev | "
(menucmd "M=$(edtime,$(getvar,date),DDDD\",\" D MONTH YYYY)"
)
" ::"
"\n:: Type \"spiralpl\" to Invoke ::"
)
)
(princ)
Regards...