copy attribute value from block to block

copy attribute value from block to block

Hans_Knol
Advocate Advocate
286 Views
1 Reply
Message 1 of 2

copy attribute value from block to block

Hans_Knol
Advocate
Advocate

Hello

 

An other challenge,

In a drawing I have some line Horizontal or Vertical, on the line is inserted a block with the name “WD_WNH” or “WD_WNV” with an Attribute named “MARK”, the Value of that attribute must be stored into an Block with Attribute what is also connected to the same line (wire) the block is called “HA1S1” “HA2S1” “HA1D1” or “HA2D1” The Attribute where it must be stored is “SIGCODE”

 

also this Lisp must be run automaticly over the drawing.

 

If the line is not connected to the block, the attribute may not be filled with the value of the “SIGCODE”

Hans Knol
0 Likes
287 Views
1 Reply
Reply (1)
Message 2 of 2

komondormrex
Mentor
Mentor

hey,

check this out

(defun c:co_attrib (/ insert_sset line_sset end_insert_sset)
	(princ "\nSelect \"WD_WN[HV]\" inserts")
	(if (setq insert_sset (ssget '((0 . "insert") (2 . "WD_WN[HV]"))))
			(foreach insert_data 
					(mapcar '(lambda (insert) (list (cdr (assoc 10 (entget insert))) (getpropertyvalue insert "mark")))
							 (vl-remove-if 'listp (mapcar 'cadr (ssnamex insert_sset)))
					)
					(if (setq line_sset (ssget "_cp" (list (mapcar '+ (car insert_data) '(-1 -1))
														   (mapcar '+ (car insert_data) '(-1 +1))
														   (mapcar '+ (car insert_data) '(+1 +1))
														   (mapcar '+ (car insert_data) '(+1 -1))
													 )
					 								'((0 . "line"))
										)
						)
						(foreach line (mapcar '(lambda (ename) (mapcar 'cdr (vl-remove-if-not '(lambda (group) (member (car group) '(10 11))) (entget ename))))
									  		   (vl-remove-if 'listp (mapcar 'cadr (ssnamex line_sset)))
									  )      
							(foreach end line
								(if (setq end_insert_sset (ssget "_x" (list '(0 . "insert") '(2 . "HA#[DS]#") (cons 10 end))))
									(vl-catch-all-apply 'setpropertyvalue (list (ssname end_insert_sset 0) "sigcode" (last insert_data)))
								)
							)
						)
					)
			)
	)
	(princ)
)
0 Likes