Moving Multiple Attributes to Multiple New Layers

Moving Multiple Attributes to Multiple New Layers

Anonymous
Not applicable
958 Views
3 Replies
Message 1 of 4

Moving Multiple Attributes to Multiple New Layers

Anonymous
Not applicable

I've read some posts on here that ask similar questions, like this one here, but I'm having some issues doing this multiple times. I have a list of attributes in different blocks with different names, and a specific layer that these attributes need to be moved to. If I hard code my function calls i.e. (c:moveAttrib attrib1 layer1) (c:moveAttrib attrib2 layer2) etc, it works perfectly. However, when I try to do this in a loop i.e (c:moveAttrib (nth counter AttribList) (nth counter LayerList)), only the last attribute is moved to its layer, and the rest stay where they were.

 

I'm using attsync after every call of moveAttrib, but I'm not sure if there's something else I need to do to make every attribute in my list move.

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

dlanorh
Advisor
Advisor
You will need to post your code inline , or attach the lisp.

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

0 Likes
Message 3 of 4

DGRL
Advisor
Advisor
Accepted solution

Hi @Anonymous

 

I guess based on info provided that you miss the  'foreach' function

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
Message 4 of 4

Anonymous
Not applicable

Thank you, that worked. I'll explain what I had been doing wrong in case anyone tried this approach.

 

I was creating attributes based on a csv file, and after I added the attribute to a block I was using the method described in the post I linked above (which I tweaked to accept both the tag and layer name and called c:moveAttrib) to try and move the newly created attribute to the layer specified in the csv file. 

 

 

(vl-load-com)
	(setq file (open "C:\\Attributes.csv" "r"))
	(while (setq listAttrib (read-line file))
		(progn
			(parse_string listAttrib)
			(setq dataAttrib lst)			
			(c:addattribs)			
		)
	)
	(close file)

But when I tried calling my moveAttrib in my addattribs function, it was only moving the last attribute specified in my csv file. So I added this line:

 

 

(setq names (append names (list (nth 0 dataAttrib))))

to my read function and after everything is read I do this in my main defun:

 

 

(foreach name names
	(progn
		(c:moveAttrib name (strcat "LAYER_" (strcase name)))
	)
)

Which works how I want.

 

Thank you everyone who helped, I've only been learning lisp for a week and these forums are a life saver.