Jump to content

layer ON/OFF , need modify


AIberto

Recommended Posts

If too many layers ( >40) ,it will be can't display ,guys ,help me modify it.

maybe need add "Page up " & "page down" ?? o:)

 

(defun c:tt (/ all_tc k2 key kwstr n)
(cxsta)
 (SETQ kwstr "\nSelect the layer for display,[ALL(x)")
 (setq n 0)
 (setq all_tc (CX-ALL-LAY))
 (foreach x all_tc
   (setq kwstr (strcat kwstr "/" x "(" (itoa n) ")"))
   (setq n (1+ n))
 )
 (setq kwstr (strcat kwstr "]"))
 (initget 128 "")
 (SETQ KEY (atoi (setq k2(GETKWORD kwstr))))
 (if (>= key 0)
    (command "_.-LAYER" "OFF" "*" "Y" "ON" (nth key all_tc) "")
 )
 (if (= k2 "x")
   (command "_.-LAYER" "ON" "*" "")
 )
 (cxend)
)

(defun CX-ALL-LAY (/ I LAY)
 (vlax-for I (vla-get-layers
(vla-get-activedocument (vlax-get-acad-object)))
   (setq LAY (cons (vla-get-name I) LAY)))
 (setq LAY (vl-sort LAY '<))
)

(defun cxsta ()
 (setvar "cmdecho" 0) 
 (setq $orr *error*)
 (setq *error* #err2) 
 (command ".UNDO" "BE")
) 

(defun cxend ()
 (command ".UNDO" "E") 
 (setq *error* $orr)
 ;(setvar "osmode" 15359)
 (prompt "finishing")
 (princ)
)



Link to comment
Share on other sites

Why not use the -LAYER / LAYER commands?

 

Hi ,lee ,thanks for reply.

 

I think this lisp is faster. can you help add "Page up " & "page down" into ?

Edited by AIberto
Link to comment
Share on other sites

Maybe relationship with the display resolution . Over the display range. will can't display .

 

I think: limited display 20 , if more than 20 , need turn the page .

 

ALL

Page up

Page down

layer1

layer2

layer3

...

...

...

layer20

 

tt.jpg

Link to comment
Share on other sites

why ? I use 2007 too.

[ATTACH=CONFIG]51867[/ATTACH]

i mean 2007 same issue, so try off the dynmode.

i can't help because i don't know which to control dynmode size/ page

 

i think Lee Mac post#3 is the solution

-layer

Link to comment
Share on other sites

Maybe relationship with the display resolution . Over the display range. will can't display .

 

I think: limited display 20 , if more than 20 , need turn the page .

 

since i can't help with dynmode,

or try alternative by displaying layer name on the screen?

then use native acad command layiso

(vl-load-com)(defun SS_ARRAY (/ i j k doc lst x ss vp rc)
 ;hanhphuc 09/12/14
 (setq doc (vlax-get-acad-object))
 (vlax-for lay	(foreach x '(ActiveDocument Layers) (setq doc (vlax-get doc x)))
   (setq lst (cons (vla-get-name lay) lst))
   ) ;_ end of vlax-for
 (if (< (length lst) [color="red"]20[/color] ); [color="blue"]min=2, you adjust here , example using lst < 20 [/color]
 [color="red"][b] (c:tt)  [/b][/color] ; [color="blue"] use your code if <20[/color]
   [color="red"][b](progn[/b][/color]
 (if (setq ss (ssget "X"))
   (while (/= (sslength ss) 0) (redraw (setq en (ssname ss 0)) 2) (setq ss (ssdel en ss)))
   ) ;_ end of if
(setq j	 (length lst)
     k	 ((lambda (n / i a b)
    (if	(not (zerop n))
      (progn (setq i (fix (sqrt n)))
	     (mapcar 'set '(a b) (list i (1+ i)))
	     (cond ((= n (* a a)) (list a a))
		   ((<= (* a a) n (* a b)) (list a b))
		   ((> n (* a b)) (list b b))
		   ) ;_ end of cond
	     ) ;_ end of progn
      ) ;_ end of if
    ) ;_ end of lambda
   j
   )
     rc (last (if (not (zerop j))
	 (cons j (list (rem (apply '* k) j) k))
	 ) ;_ end of if
       ) ;_ end of last
     vp ((lambda (% / dv vH vW lst) ; v1.1
    (setq vH (getvar "viewsize")
	  vW (*	vH
		(/ 1.
		   (apply
		     '/
		     (cdr
		       (reverse
			 (apply	'mapcar
				(cons '- (cdr (setq dv (mapcar ''((x) (trans (getvar x) 0 1)) 
                             '(viewctr vsmin vsmax))))) 
				) ;_ end of apply
			 ) ;_ end of reverse
		       ) ;_ end of cdr
		     ) ;_ end of apply
		   ) ;_ end of /
		) ;_ end of *
	  ) ;_ end of setq
    (foreach x '(+ -)
      (setq lst	(cons (mapcar ''((i j) ((eval x) (i (car dv)) (* (* j 0.5) (/ % 100.))))
			      (list car cadr)
			      (list vW vH)
			      ) ;_ end of mapcar
		      lst
		      ) ;_ end of cons
	    ) ;_ end of setq
      ) ;_ end of foreach
    ) ;_ end of lambda
   80.
   )
     ) ;_ end of setq
 (vla-arrayrectangular
   (vlax-ename->vla-object
     (entmakex	(vl-list* '(0 . "TEXT")
		  '(1 . "*")
		  '(72 . 4)
		  (cons 40 (* (/ (getvar 'viewsize) (cadr (getvar 'screensize))) 7.))
		  (mapcar ''((x) (cons x (car vp))) '(10 11))
		  ) ;_ end of list
	) ;_ end of entmakex
     ) ;_ end of vlax-ename->vla-object
   (car rc) ;row
   (cadr rc) ;col
   1
   (/ (- (cadadr vp) (cadar vp)) (- (car rc) 1.))
   (/ (- (caadr vp) (caar vp)) (- (cadr rc) 1.))
   1.
   ) ;_ end of vla-arrayrectangular
 (setq ss (ssget "X" (list (cons 0 "TEXT"))))
 (if (> (setq c (- (setq x (sslength ss)) (length lst))) 0)
   (repeat c (entdel (setq e (ssname ss (setq x (1- x))))) (ssdel e ss))
   ) ;_ end of if
 (repeat (setq i (sslength ss))
   (setq i (1- i))
   (mapcar ''((x) (vlax-put (vlax-ename->vla-object (ssname ss i)) x (nth i (acad_strlsort lst))))
    '(Layer TextString)
    ) ;_ end of mapcar
   ) ;_ end of repeat
[color="red"][b]  ) ;_end of progn[/b][/color]
)
 (terpri)
 ss
 ) ;_ end of defun

 


(defun c:test (/ *error* ss e on)
 (defun *error* (msg)
   (if	on
     (command "layerp")
     ) ;_ end of if
   (if	ss
     (command "_erase" ss "")
     ) ;_ end of if
   (if	(> (getvar "cmdactive") 0)
     (princ)
     ) ;_ end of if
   (command "regen")
   (if	(not (wcmatch (strcase msg) "*CANCEL*,*EXIT*"))
     (princ (strcat "\n*error : " msg))
     ) ;_ end of if
   ) ;_ end of defun 
 (command "_layer" "U" "*" "")
 (setq on (vl-cmdf "_layer" "on" "*" "")[color="red"][b] ss (SS_ARRAY)[/b][/color])
 (if (and [color="red"][b]ss[/b][/color]
   (setq s (ssget [color="red"][b][color="red"]"_+.:S:E:L"[/color][/b][/color])) ; <--[color="blue"] you can change mode [/color]
   ) ;_ end of and
   (progn (command "_layiso" s "") (setq on nil)) ;_ end of progn
   ) ;_ end of if
 (command "regen")
[color="red"][b] (if ss[/b][/color] (exit)[color="red"][b])[/b][/color]
 (princ)
 ) ;_ end of defun

Edited by hanhphuc
editted in red bold
Link to comment
Share on other sites

since i can't help with dynmode,

or try alternative by displaying layer name on the screen?

then use native acad command layiso

 

Thanks my dear friend , why you can't use DYN (dynmode) mode ? A2007 can do this .

Thank you for your efforts, but this method is not fast.

Link to comment
Share on other sites

Dear hanhphuc. Thanks you for your time. This issue is not important. Don't need to spend any more time .

 

sharing a function:

 

(defun Spline:Box (obj / cpts vec p1 p2 p4 p3 lst xdir ydir)
 (setq        cpts (mapcar
              'cdr
              (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget obj))
            )
       p1   (apply 'mapcar (cons 'min cpts))
       p3   (apply 'mapcar (cons 'max cpts))
 )
 (if (zerop (getvar "worlducs"))
   (setq vec  (mapcar '- p3 p1)
         p2   (mapcar '+ p1 (list (car vec) 0.0 0.0))
         p4   (mapcar '+ p1 (list 0.0 (cadr vec) 0.0))
         lst  (list
                (trans p1 0 1)
                (trans p2 0 1)
                (trans p3 0 1)
                (trans p4 0 1)
              )
         p1   (trans (apply 'mapcar (cons 'min lst)) 1 0)
         p3   (trans (apply 'mapcar (cons 'max lst)) 1 0)
         xdir (getvar "ucsxdir")
         ydir (getvar "ucsydir")
   )
   (setq xdir '(1.0 0.0 0.0)
         ydir '(0.0 1.0 0.0)
   )
 )
 (setq
   lst        (mapcar        '(lambda (a b)
                  (vlax-curve-getClosestPointToProjection obj a b t)
                )
               (list p1 p1 p3 p3)
               (list xdir ydir xdir ydir)
       )
 )
 (if (zerop (getvar "worlducs"))
   (setq lst (mapcar '(lambda (x) (trans x 0 1)) lst))
 )
 (setq        p1 (apply 'mapcar (cons 'min lst))
       p3 (apply 'mapcar (cons 'max lst))
 )
 (mapcar '(lambda (x) (trans x 1 0))
         (list        p1
               (list (car p1) (cadr p3) (caddr p1))
               p3
               (list (car p3) (cadr p1) (caddr p1))
         )
 )
)

Link to comment
Share on other sites

Thanks my dear friend , why you can't use DYN (dynmode) mode ? A2007 can do this .

Thank you for your efforts, but this method is not fast.

 

v2007 does have dynmode, but only issue is limited display depend on screen size.

your (c:tt) is faster by keying, so i fixed a bit to single isolate. post#9

Link to comment
Share on other sites

v2007 does have dynmode, but only issue is limited display depend on screen size.

your (c:tt) is faster by keying, so i fixed a bit to single isolate. post#9

 

I think use DLC is better than this method . Because, Font is too small. ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...