help with lisp to loop through a layer and change it linens to other layer based on it's color

help with lisp to loop through a layer and change it linens to other layer based on it's color

aridzv
Enthusiast Enthusiast
2,599 Views
22 Replies
Message 1 of 23

help with lisp to loop through a layer and change it linens to other layer based on it's color

aridzv
Enthusiast
Enthusiast

Hi.

i'm importing a file from hydraulic calculation software,

and all the lines that represent pipe are in one layer and are different by color.

i'm looking for a lisp that will loop through this layer and will change each line to a different Existing layer based on its color,

For example:

the original layer called "Pipes", and some of the line's color is 140,some are color 112.

i want to change all of those lines of color 140 to an existing layer called DN110,and all of those lines of color 112 to an existing layer called DN75. 

 

Thanks,

Ari

0 Likes
Accepted solutions (2)
2,600 Views
22 Replies
Replies (22)
Message 21 of 23

pbejse
Mentor
Mentor
Accepted solution

@aridzv wrote:

you are right!

here are 2 files:

1. dwg drawing with the source drawing,a legend of the new lines and all the necessary layers.

2. the modified LSP file with all the layers names (to save work..)

 

Thanks,

Ari. 


I made a booboo :D. variable e is missing

 

 

(setq ent (entget (setq e (ssname ss (setq i (1- i))))))

 

 

Other than that it should work. 

 

** Note that the filter is searching for a LINES on "Submain pipes" layer. which is 340 on your drawing.

You can remove the layer filter 

 

 

(setq ss (ssget "_X" (append
			 '((0 . "LINE")(-4 . "<OR"))
			     (mapcar '(lambda (c)(cons 62 c))
				       (mapcar 'car Datalist))
			 '((-4 . "OR>"))))
	    )

 

Which makes the selection 386.

IMO including a layer filter is better, but you need to make a list of the layers as well. Let me know if you need help with that.

 

Also, we can make an external file as source for the datalist. that way you dont need to modifty the lisp to work on other conditions.

Message 22 of 23

aridzv
Enthusiast
Enthusiast

 

THANKS!!!

Working Perfectly!!

Ari.

0 Likes
Message 23 of 23

aridzv
Enthusiast
Enthusiast

"...Also, we can make an external file as source for the datalist. that way you dont need to modifty the lisp to work on other conditions."

that is an interesting idea!

it will be wonderful if you will do it,it will be a grate help.

Thanks.

0 Likes