;;; Select Hatches with same scale as scale of user selected hatch
;;; Based on ttray33y approach: http://www.cadtutor.net/forum/showthread.php?90752-Lisp-for-selecting-hatches-based-on-scale
;;; Slightly modified by Igal Averbuh 2017 (added option to operate with Scale of user selected hatch)

; to change the pattern scale
;(vla-put-patternscale hatchObject 2.0)

(defun C:hs(/ ent count)
(vl-load-com)
(setvar "cmdecho" 0)

; select hatch entity and get the ename
(setq hatchObject (car (entsel "\nSelect example hatch object: ")))

; convert the ename to a vla-object
(setq hatchObject (vlax-ename->vla-object hatchObject))

; to get the pattern scale
(setq Sel (vla-get-patternscale hatchObject))

(setq ent(ssget (list(cons 0 "HATCH")(cons 41 Sel))))

(if (and ent (> (sslength ent) 0))

(progn
(setq count(sslength ent))

(princ (strcat "Selected " (itoa count) " Hatches."))

)
)
(setvar "cmdecho" 1)
(princ)
)

(princ)
(c:hs)

Advertisements