I undestand
I modify Selpoly to SelWpoly (select _WP) and add filter
- (defun SELWPOLY ( filter / pl lst ss);;; Selecting objects by polyline (window polygon);;; filter - filter list like ssget functions or nil - not;;; example (setq filter (list(cons 0 "LWPOLYLINE")(cons 8 "Buildings")));;; Return - PICKSET ;| ! *******************************************************************;; ! _IsPtInView;; ! *******************************************************************;; ! Checks whether a point in the viewport;; ! Auguments: 'pt' - Point for analysis in World!!!;; ! Return : T or nil if 'pt' in the viewport or not;; ! *******************************************************************|;(defun _get-viewctr-size ( / VCTR Y_Len SSZ X_Pix Y_Pix X_Len) (setq VCTR (getvar "VIEWCTR") Y_Len (getvar "VIEWSIZE") SSZ (getvar "SCREENSIZE") X_Pix (car SSZ) Y_Pix (cadr SSZ) X_Len (* (/ X_Pix Y_Pix) Y_Len)) (list(mapcar '- VCTR (list (* 0.5 X_len)(* 0.5 Y_len))) (mapcar '+ VCTR (list (* 0.5 X_len)(* 0.5 Y_len)))))(defun _IsPtInView (pt / Lc Uc)(setq pt (trans pt 0 1))(setq Lc (_get-viewctr-size) Uc (cadr Lc) Lc (car Lc)) (if (and (> (car pt) (car Lc))(< (car pt) (car Uc)) (> (cadr pt) (cadr Lc))(< (cadr pt) (cadr Uc)) )T nil));| ! ***************************************************************************;; ! _pt_extents;; ! ***************************************************************************;; ! Function: Returns the bounds of MIN, MAX X, Y, Z points list;; ! Argument: 'vlist' - A list of points;; ! Returns: list of points (LevNizhn PravVerhn);; ! ***************************************************************************|;(defun _pt_extents (vlist / tmp) (setq tmp (apply 'mapcar (cons 'list vlist))) (list (mapcar '(lambda(x)(apply 'min x)) tmp)(mapcar '(lambda(x)(apply 'max x)) tmp)));_defun;;! _Zoom2Lst;;! **********************************************************;;! Function: Zoom boundary points list;;! Arguments: 'vlist' - A list of points in the World!!;;! Zoom screen, so that all points were visible;;! Returns: t - was zooming nil - no;;! ********************************************************** (defun _Zoom2Lst (vlist / pts) (setq pts (_pt_extents (mapcar '(lambda(x)(list (car x)(cadr x))) vlist))) (if (not (and (_IsPtInView (car pts)) (_IsPtInView (cadr pts)))) (progn (vla-ZoomWindow (vlax-get-acad-object)(vlax-3d-point (car pts))(vlax-3d-point (cadr pts)))(vlax-invoke (vlax-get-acad-object) 'ZoomScaled 0.85 acZoomScaledRelative)T) nil ) ) ;end(defun mip:entsel (promt filter entlist / key n newentlist ent_point promt);;; Single choice object, replacing the function entsel;;; Returns entity name selected entity or nil,specifying point stored in the variable LASTPOINT;;; Parameters:;;; promt - a proposal to select an object (string);;; filter - a filter to select the type of objects' ("LINE" "LWPOLYLINE");;; entlist - a list of entities that do not have to choose (or a list of entity name, or PICKSET);;;;;; Examples:;;; (mip: entsel "\ nPlease select objects" '("LINE" "LWPOLYLINE") nil);;; (mip: entsel "\ nPlease select objects" nil nil);;; (setq aa nil) (mip: entsel "\ nPlease select objects" '("LINE" "LWPOLYLINE") (while (setq a (car (entsel))) (setq aa (append aa (list a))) ));;; (mip: entsel "\ nPlease select objects" '("LINE" "LWPOLYLINE") (ssget)) (setq key T n 0 newentlist nil) (if (eq (type entlist) 'PICKSET) (progn (while (setq a (ssname entlist n)) (setq newentlist (append newentlist (list a)) n (1+ n))) (setq entlist newentlist) );progn );if (while key (if (or (setq ent_point (entsel promt)) (= (getvar "ERRNO") 7)) (if (or (eq (type ent_point) 'LIST) (not ent_point)) (if ent_point (if (member (setq ent (car ent_point)) entlist) (princ "\nThe primitive has been selected") (if filter (if (not (member (cdr (assoc 0 (entget ent))) filter)) (progn (setq str "\nNot the right choice, choose: ") (princ (substr (setq str (foreach n filter (setq str (strcat str n ", ")))) 1 (- (strlen str) 2))) );progn (setq key nil) );if (setq key nil) );if );if (setq key T) );if (setq key nil) );if (setq key nil) );if );while (if (eq (type ent_point) 'LIST) (progn (setvar "LASTPOINT" (cadr ent_point)) ent) ent_point );if);defun(defun massoc (key alist / x nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) )) (reverse nlist)) (vl-load-com)(and (setq pl (mip:entsel "\nSelect Polyline" '("LWPOLYLINE") nil)) (setq lst (massoc 10 (entget pl))) (or (_Zoom2Lst lst) t) (setq ss nilss (if filter (ssget "_WP" (mapcar '(lambda(x)(trans x 0 1)) lst) filter ) (ssget "_WP" (mapcar '(lambda(x)(trans x 0 1)) lst) ) )) (sssetfirst nil ss) ) ss )(defun C:SELWPOLY()(SELWPOLY nil))(princ "\nType SELWPOLY in command line")
How to create Custom command (use function selwpoly and filter list)
[code](defun C:CUSTOM1 ( / ss tstyle) ;;; (setq *TEXTSIZE* (getvar "TEXTSIZE")) ;_Text height (setq *TEXTSIZE* 0.0005) ;_Text height |