Move PLine and Line specific color to other layer

Move PLine and Line specific color to other layer

mbelleza
Participant Participant
1,068 Views
3 Replies
Message 1 of 4

Move PLine and Line specific color to other layer

mbelleza
Participant
Participant

Hi,

 

I have lines and polylines in two different colors (150 and 200) in the same layer, layer W for now.

I would like to move all color 150 lines and polylines to layer Y and the color 200 to layer Z.

I know that I need to use something like this:

(setq ss (ssget "X" '((0 . "*TEXT") (62 . 1)))

 I dont know how to limit the search to layer W.

 

0 Likes
Accepted solutions (1)
1,069 Views
3 Replies
Replies (3)
Message 2 of 4

dlanorh
Advisor
Advisor
Accepted solution

Try this. Not tested as I'm no acad on this laptop.

 

The (8 . "W") in the ssget line is how you filter for the layer

 

(defun c:test ( / c_doc ss)
	(setq   c_doc (vla-get-activedocument (vlax-get-acad-object))
		ss (ssget "_X" '((0 . "LINE,*POLYLINE") (8 . "W")))
	)
	(vlax-for obj (vla-get-activeselectionset c_doc)
	  (if (= (vlax-get-property obj 'color) 150) (vlax-put-property obj 'layer "Y"))
	  (if (= (vlax-get-property obj 'color) 200) (vlax-put-property obj 'layer "Z"))
	)
)	

I am not one of the robots you're looking for

Message 3 of 4

mbelleza
Participant
Participant

It works, thank you very much!!!

0 Likes
Message 4 of 4

dlanorh
Advisor
Advisor

@dlanorh wrote:

Try this. Not tested as I'm no acad on this laptop.

 

The (8 . "W") in the ssget line is how you filter for the layer

 

(defun c:test ( / c_doc ss)
(vl-load-com) (setq c_doc (vla-get-activedocument (vlax-get-acad-object)) ss (ssget "_X" '((0 . "LINE,*POLYLINE") (8 . "W"))) ) (vlax-for obj (vla-get-activeselectionset c_doc) (if (= (vlax-get-property obj 'color) 150) (vlax-put-property obj 'layer "Y")) (if (= (vlax-get-property obj 'color) 200) (vlax-put-property obj 'layer "Z")) ) )

Amended code : Forgot the (vl-load-com)

I am not one of the robots you're looking for

0 Likes