Message 1 of 5

Not applicable
01-09-2020
11:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How do I create a matched selection set against a previously selected block?
For example, Select block01 and store the attribute value in a variable.
From here I want to select another block that is at most 5m away and write the value stored in my variable.
examples of my attempts.
;;--------------------- { Get Attribute Value - Lee Mac } --------------------;; ;; ;; ;;------------------------------------------------------------------------------;; ;; Autor: Lee Mac ;; ;;------------------------------------------------------------------------------;; ;; Argumentos: ;; ;; blk - [vla] VLA Block Reference Object ;; ;; tag - [str] Attribute TagString ;; ;;------------------------------------------------------------------------------;; (defun LM:vl-getattributevalue ( blk tag ) (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) ;;--------------------- { Set attributevalue - Lee Mac- } --------------------;; ;; ;; ;;------------------------------------------------------------------------------;; ;; Autor: Lee Mac ;; ;;------------------------------------------------------------------------------;; ;; Argumentos: ;; ;; blk - [vla] VLA Block Reference Object ;; ;; tag - [str] Attribute TagString ;; ;; val - [str] Attribute Value ;; ;;------------------------------------------------------------------------------;; (defun LM:vl-setattributevalue ( blk tag val ) (setq tag (strcase tag)) (vl-some '(lambda ( att )(if (= tag (strcase (vla-get-tagstring att))) (progn (vla-put-textstring att val) val)))(vlax-invoke blk 'getattributes)) ) ;;------------------------------------------------------------------------------;; (defun c:TEST (/ ss id iv blk blk2 ) (setq ss (ssget ":L" '((0 . "INSERT")(66 . 1)))) ;; Select blk (repeat (setq id (sslength ss)) (setq blk (vlax-ename->vla-object (ssname ss (setq id (1- id))))) (setq iv (LM:vl-getattributevalue blk "ATTBLK01")) ;; >> Select block within 5m of distance (setq blk2 (vlax-ename->vla-object ;|(car (entsel))))|;;;<< I don't know how the selection will be (LM:vl-setattributevalue blk "ATTBLK02" blk2) ) (princ) )
Solved! Go to Solution.