leonucadomi Posted December 9, 2022 Posted December 9, 2022 can someone help me to extract the value of the attributes inside a block? Here I put the example of the block that I use. I want to extract the value "2000" and put it in a variable. thank you for your advices BLOCK.dwg Quote
mhupp Posted December 9, 2022 Posted December 9, 2022 getproperyvalue doesn't work in BricsCAD so I can't test this. This will ask you to select a block and if it has DAT2 attribute it will 1 set variable x to its value (can be called later) 2 copy that value to the clipboard (ctr+V to paste) (defun C:foo (/ html) (vl-load-com) (if (setq x (getpropertyvalue (car (entsel "\nSelect Block")) "DAT2")) (vlax-invoke (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" x) ) (vlax-release-object html) (princ) ) 1 Quote
robierzo Posted December 9, 2022 Posted December 9, 2022 another (defun LM:vl-getattributevalue ( blk tag );LEE MAC (setq tag (strcase tag)) (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) (defun c:sel_block () (while (setq obj_block (vlax-ename->vla-object (car (entsel "\nSelecciona bloque: ")))) (setq dato2 (LM:vl-getattributevalue obj_block "DATO2")) (princ dato2) ) ) 1 Quote
leonucadomi Posted December 9, 2022 Author Posted December 9, 2022 this is great thanks for your help Quote
BIGAL Posted December 9, 2022 Posted December 9, 2022 If you are happy to pick an attribute directly then can do this. Uses Nentsel rather than entsel. (setq attstr (cdr (assoc 1 (entget (car (nentsel "\nPick attribute ")))))) 2 Quote
Recommended Posts
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.