Jump to content

extract value of block...help


leonucadomi

Recommended Posts

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

Link to comment
Share on other sites

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)
)

 

  • Like 1
Link to comment
Share on other sites

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)
  )
)

 

  • Like 1
Link to comment
Share on other sites

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 "))))))

 

  • Like 2
Link to comment
Share on other sites

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...