confused with attribute acquiring method

confused with attribute acquiring method

8727276
Participant Participant
341 Views
3 Replies
Message 1 of 4

confused with attribute acquiring method

8727276
Participant
Participant

when I use "entget" in the selection of block with attribute, only "insert" can be found and no other entity in the selection set, as below part 1, I can only find the attached attribute in the block with the entnext as below part 2, hwta's the reason, and is it possible I can get attribute value in the blcok with one time selection? 

 

(setq s (ssget))

命令: (setq A (entget (ssname s 0)))
((-1 . <图元名: 1f224f2a890>) (0 . "INSERT") (330 . <图元名: 1f27c407f00>) (5 . "19D9") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "MCCB") (10 0.0 0.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

 

 

 

(setq a (entnext (ssname s 0)))

(setq B (entget a))
((-1 . <图元名: 1f224f2a8b0>) (0 . "ATTRIB") (330 . <图元名: 1f224f2a890>) (5 . "19DB") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbText") (10 4390.22 266.345 0.0) (40 . 2.0) (1 . "16A") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbAttribute") (280 . 0) (2 . "SETTING") (70 . 0) (73 . 0) (74 . 0) (280 . 1))

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

paullimapa
Mentor
Mentor
Accepted solution

yes, initially, this is the only autolisp method available to retrieve attributes inside a block by cycling through using entnext or you can also uses visual lisp functions like what's described here

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 4

Sea-Haven
Mentor
Mentor

If you want to pick one attribute only then (Nentsel "\nPick attribute ") it will return the attribute properties selected.

Message 4 of 4

8727276
Participant
Participant

yes, thanks for the hints, I drafted below lisp program to extract the text and Attribe from the selected block. and return a list. it works after many times transformation,  little complicated. 

(setq N 0)
(setq S1 '())
(Repeat Num
(setq SS (entget (SSname S0 N))) ;aquired a entity data under the SS name
(if (or (= (CDR (Assoc 0 SS)) "MTEXT") (= (CDR (Assoc 0 SS)) "TEXT")) (Setq S1 (cons (list (CDR (Assoc 10 SS)) (CDR (Assoc 1 SS))) s1)));sorting location and text out
(if (= (CDR (Assoc 0 SS)) "insert")
(progn
(setq p1 (vlax-ename->vla-object (SSname S0 N)))
(setq p3 (vlax-invoke p1 'GetAttributes) i 0)
(repeat (length p3)
(setq P (vlax-safearray->list (vlax-variant-value (vlax-get-property (nth i p3) "InsertionPoint"))))
(setq Tex (vlax-get-property (nth i p3) "TextString"))
(Setq S1 (cons (list P Tex) s1))
(setq i (1+ i))
)
)
)
(setq N (1+ N))
)

 

got final result as below:

 

(((4390.22 255.268 0.0) "16A") ((4390.62 196.11 0.0) "ZR-YJV22-0.6/1kV-5X6-DN32") ((4376.86 177.483 0.0) "3U-UPS-FC-204") ((4378.48 172.459 0.0) "2F NORTH SUB"))

 

0 Likes