Jump to content

help with routine get attribute value


leonucadomi

Recommended Posts

hello:

I have a code that extracts the data from a block with attributes.

but you have to select the block with click.

 

knowing that the block is called "block1 or block2" always

 

I want to ask for your help to modify the code and not have to select anything with click.

if not do it automatically.

 

thanks

 

 

here the code...

 

(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:pru ()
  (while (setq obj_block (vlax-ename->vla-object (car (entsel "\nSelecciona bloque: "))))
    (setq dato2 (LM:vl-getattributevalue obj_block "DATO2"))
    (princ dato2)
  )
)

 

Link to comment
Share on other sites

I think this routine can help me but I don't know how to use it, does anyone know?

 

;; Get Attribute Value  -  Lee Mac
;; Returns the value held by the specified tag within the supplied block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; Returns: [str] Attribute value, else nil if tag is not found.

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

 

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