Hiding a Layer/Symbol Start of a command and turning it back on when command end

Hiding a Layer/Symbol Start of a command and turning it back on when command end

Kyle.Pederson
Advocate Advocate
1,072 Views
7 Replies
Message 1 of 8

Hiding a Layer/Symbol Start of a command and turning it back on when command end

Kyle.Pederson
Advocate
Advocate

Could Someone explain how I could turn off or isolate a Particular Layer/symbol during a command and turn it back on after command is over?

Example would be LayerA, Symbol1, Symbol2, Symbol3. All need to be hidden before this area command is ran

0 Likes
Accepted solutions (1)
1,073 Views
7 Replies
Replies (7)
Message 2 of 8

ronjonp
Mentor
Mentor

Something like this?

;; Turn off and gather
(vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
  (cond	((wcmatch (strcase (vla-get-name x)) "LAYERA,SYMBOL[1-3]")
	 (vla-put-layeron x :vlax-false)
	 (setq l (cons x l))
	)
  )
)
;; Your code

;; Then turn them back on
(foreach x l (vla-put-layeron x :vlax-true))

 

A simpler solution would be to not include those layers in your selection set:

(ssget '((0 . "ARC,CIRCLE,LINE,*POLYLINE,REGION,SPLINE,ELLIPSE")
	 (8 . "~LayerA")
	 (8 . "~SYMBOL[1-3]")
	)
)

 

Message 3 of 8

john.uhden
Mentor
Mentor

I'm a little confused.  Do you mean to change a layer's visibility property to OFF, or do you mean to eliminate the name from a list of layer names?

John F. Uhden

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

Also for clarification, are the "Symbol" entries just other Layer names, as Message 2 interprets it, or is a "Symbol" something different from  a "Layer," and if so, what do you mean by it?

Kent Cooper, AIA
0 Likes
Message 5 of 8

Kyle.Pederson
Advocate
Advocate

test.PNG

My issue is trying to accommodate older and newer drawings. Older drawings did not always have Tool Palette Blocks Saved under the correct layer. Newer drawings always have the Tool Palette Blocks saved under the layer "Symbols"

 

When I Run the Boundary Command It traces around certain Blocks that are placed on the actual Polyline. (Ex. Overhead Door) I'd like to have the Boundary Command go thru the Block to be a perfect Rectangle.

 

Seems like my best option to get around this is to Turn off Layer "Symbols" and/or Isolate a particular Tool palette Block during the beginning of the command, then have them all turn back on once command is done.

 

(defun C:Test1 (/ pt)
  (while (setq pt (getpoint "\nPick in closed area: "))
    (command "_.boundary" pt "")
  )
)

 

0 Likes
Message 6 of 8

Kyle.Pederson
Advocate
Advocate

Layers to change visibility to Off and Tool Palette Blocks Isolate>Hide objects

0 Likes
Message 7 of 8

ronjonp
Mentor
Mentor

The first code snippet I posted should do what you want.

0 Likes
Message 8 of 8

ronjonp
Mentor
Mentor
Accepted solution

Not sure how code savvy you are, but this is what I meant above:

(defun c:test1 (/ l pt)
  ;; Turn off and gather
  (vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    (cond ((wcmatch (strcase (vla-get-name x)) "LAYERA,SYMBOL*")
	   (vla-put-layeron x :vlax-false)
	   (setq l (cons x l))
	  )
    )
  )
  (while (setq pt (getpoint "\nPick in closed area: ")) (command "_.boundary" pt ""))
  ;; Then turn them back on
  (foreach x l (vla-put-layeron x :vlax-true))
  (princ)
)
(vl-load-com)