Jump to content

Select Block, Assign Attribute Value with Stored Variable


Recommended Posts

Posted
Try something like this:

(defun c:foo (/ _foo a b s)
 ;; RJP » 2018-08-02
 (defun _foo (b tag f)
   (vl-some '(lambda (x)
	(cond ((= (strcase tag) (strcase (vla-get-tagstring x)))
	       (if f
		 (not (vla-put-textstring x f))
		 (vla-get-textstring x)
	       )
	      )
	)
      )
     (vlax-invoke b 'getattributes)
   )
 )
 (cond
   ((and (setq s (ssget ":L" '((0 . "insert") (66 . 1))))
  (setq s (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))))
    )
    ;; Enter your tagnames here
    (foreach tag [color="red"]'(("LINE-ID" "LINE_NO") ("TAGTOGETVALUE" "TAGTOPUTVALUE") ("SERVICE" "SERVICE"))[/color]
      (if (setq
     a (vl-some
	 '(lambda (x)
	    (cond
	      ((= "PID-LINE-ID" (strcase (vla-get-effectivename x))) (_foo x (car tag) nil))
	    )
	  )
	 s
       )
   )
 (setq b (cons (list a (cadr tag)) b))
      )
    )
    (foreach x s (foreach v b (_foo x (cadr v) (car v))))
   )
 )
 (princ)
)

 

Works perfectly. Once again, thanks for the help!

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • ronjonp

    10

  • atb1984

    6

  • rlx

    3

  • Grrr

    2

Top Posters In This Topic

Posted
Works perfectly. Once again, thanks for the help!

 

Glad to help :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...