Filter out only attributes in current visibility state (vlax-invoke obj 'getattributes)

Filter out only attributes in current visibility state (vlax-invoke obj 'getattributes)

r_de_nier
Contributor Contributor
485 Views
6 Replies
Message 1 of 7

Filter out only attributes in current visibility state (vlax-invoke obj 'getattributes)

r_de_nier
Contributor
Contributor

I used the following line in my routine:

(setq listattributes (mapcar '(lambda ( att ) (cons (vla-get-tagstring att) (vla-get-textstring att))) (vlax-invoke obj 'getattributes)))

 

I get the complete list of attribute values in a dynamic block as it should.

But I want only the attributes that are visibible in the current visibility state. Is there a way to filter these attribute values out of the complete list?

0 Likes
486 Views
6 Replies
Replies (6)
Message 2 of 7

Sea-Haven
Mentor
Mentor

Looking at attributes may be the wrong direction rather need to look at Visibility properties but its rather deep. Looking into lots of values in a entget is something I struggle with. This is a visibility property dump.

(entget vis)
((-1 . <Entity name: 66a2b2b0>) (0 . "BLOCKVISIBILITYPARAMETER") (5 . "914F3B") (330 . <Entity name: 66a2a4b0>) (100 . "AcDbEvalExpr") (90 . 32) (98 . 33) (99 . 155) (100 . "AcDbBlockElement") (300 . "Visibility State") (98 . 27) (99 . 1) (1071 . 0) (100 . "AcDbBlockParameter") (280 . 1) (281 . 0) (100 . "AcDbBlock1PtParameter") (1010 1674.xxx-xxxxxxxx 1637.xxx-xxxxxxxx 0.0) (93 . 33) (170 . 0) (171 . 0) (100 . "AcDbBlockVisibilityParameter") (281 . 1) (301 . "Visibility1") (302 . "") (91 . 0) (93 . 10) (331 . <Entity name: 66a2b070>) (331 . <Entity name: 66a2b6f0>) (331 . <Entity name: 66a2b430>) (331 . <Entity name: 66a2b370>) (331 . <Entity name: 66a2aff0>) (331 . <Entity name: 66a2acf0>) (331 . <Entity name: 66a2b770>) (331 . <Entity name: 66a2b830>) (331 . <Entity name: 66a2b8f0>) (331 . <Entity name: 66a2b330>) (92 . 4) (303 . "Awning-Top Hung") (94 . 7) (332 . <Entity name: 66a2b770>) (332 . <Entity name: 66a2acf0>) (332 . <Entity name: 66a2b6f0>) (332 . <Entity name: 66a2b070>) (332 . <Entity name: 66a2b370>) (332 . <Entity name: 66a2b8f0>) (332 . <Entity name: 66a2b330>) (95 . 7) (333 . <Entity name: 66a2ae70>) (333 . <Entity name: 66a2b6b0>) (333 . <Entity name: 66a2b630>) (333 . <Entity name: 66a2b5f0>) (333 . <Entity name: 66a29af0>) (333 . <Entity name: 66a29b30>) (333 . <Entity name: 66a2ae30>) (303 . "Awning-Bottom Hung") (94 . 6) (332 . <Entity name: 66a2b770>) (332 . <Entity name: 66a2b070>) (332 . <Entity name: 66a2acf0>) (332 . <Entity name: 66a2b370>) (332 . <Entity name: 66a2aff0>) (332 . <Entity name: 66a2b8f0>) (95 . 7) (333 . <Entity name: 66a2ae30>) (333 . <Entity name: 66a29af0>) (333 . <Entity name: 66a29b30>) (333 . <Entity name: 66a2b5f0>) (333 . <Entity name: 66a2b630>) (333 . <Entity name: 66a2b6b0>) (333 . <Entity name: 66a2ae70>) (303 . "Casement-Left hinged") (94 . 6) (332 . <Entity name: 66a2b770>) (332 . <Entity name: 66a2acf0>) (332 . <Entity name: 66a2b070>) (332 . <Entity name: 66a2b370>) (332 . <Entity name: 66a2b830>) (332 . <Entity name: 66a2b8f0>) (95 . 😎 (333 . <Entity name: 66a2b8b0>) (333 . <Entity name: 66a2ae70>) (333 . <Entity name: 66a2b6b0>) (333 . <Entity name: 66a2b630>) (333 . <Entity name: 66a2b5f0>) (333 . <Entity name: 66a29b30>) (333 . <Entity name: 66a2ae30>) (333 . <Entity name: 66a29af0>) (303 . "Casement-Right hinged") (94 . 6) (332 . <Entity name: 66a2b770>) (332 . <Entity name: 66a2b070>) (332 . <Entity name: 66a2acf0>) (332 . <Entity name: 66a2b370>) (332 . <Entity name: 66a2b430>) (332 . <Entity name: 66a2b8f0>) (95 . 😎 (333 . <Entity name: 66a2b6b0>) (333 . <Entity name: 66a2ae70>) (333 . <Entity name: 66a2b630>) (333 . <Entity name: 66a2b5f0>) (333 . <Entity name: 66a29b30>) (333 . <Entity name: 66a29af0>) (333 . <Entity name: 66a2ae30>) (333 . <Entity name: 66a2b8b0>))
: (cdr (assoc 301 (entget vis)))
"Visibility1"

Some one may be able to dig deeper I started with Lee-mac dynamic block properties. 

 

Need a dwg with sample block.

0 Likes
Message 3 of 7

r_de_nier
Contributor
Contributor

Thanks for your reaction Sea-Haven. I have attached a traffic sign from witch I like to have only teh attributes that are in the current visibility state. I quess your sollution might work.

 

0 Likes
Message 4 of 7

r_de_nier
Contributor
Contributor
I do not have any idea how to get deeper in the dxf structure to get at the current visibility state.
This is how far I come. (SETQ ENT1 (ENTGET SSN))
((-1 . <Entity name: 18f02ce81b0>) (0 . "INSERT") (5 . "137FBB") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: 18f02ce81c0>) (102 . "}") (330 . <Entity name: 18e2dc6d820>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "*U497") (10 17962.7 57540.7 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))
0 Likes
Message 5 of 7

ВeekeeCZ
Consultant
Consultant

Well, it could be kinda simple if the particular visibility state is current.

 

(defun c:test ()
  
  (foreach o (vlax-invoke (vlax-ename->vla-object (car (entsel "Select block: "))) 'getattributes)
    (if (= :vlax-true (vla-get-visible o))
      (princ (strcat "\nValue of " (vla-get-tagstring o) " is " (vla-get-textstring o)))))
  (princ)
  )

 

 

0 Likes
Message 6 of 7

komondormrex
Mentor
Mentor

to sort off invisible attributes

(vl-remove-if '(lambda (attribute) (zerop (vlax-get attribute 'visible)))
  		   (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes)
)

 

0 Likes
Message 7 of 7

r_de_nier
Contributor
Contributor

 Thank you for your great help! I've got a deeper understanding of this matter now and it was the solution of my problem.

0 Likes