Jump to content
ktbjx

Extract specific Attribures to text or mtext

Recommended Posts

ktbjx

i found this lisp here on cad tutor. and it works great!

but i was just wondering if i could just extract a specific attributes to text or mtext.

here is the thread:

http://www.cadtutor.net/forum/showthread.php?56833-Display-ATTRIBUTES-as-Text-from-multiple-blocks&highlight=attmt

 

 

i only needed the attributes "Hole_ID"

can someone help?

Attmt.LSP

Share this post


Link to post
Share on other sites
Dadgad

Try using the command NCOPY (NestedCopy), a great command.

Share this post


Link to post
Share on other sites
BIGAL

Like others here you pick a block and you getattributes looking for tag name = "Hole_id"

 

No error checking just a crude example of picking a block and finding "Hole_id"

(foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes)
       (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
       (alert (strcat "value found is "(vla-get-textstring att )))
       )
)

Share this post


Link to post
Share on other sites
ktbjx
Like others here you pick a block and you getattributes looking for tag name = "Hole_id"

 

No error checking just a crude example of picking a block and finding "Hole_id"

(foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes)
       (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
       (alert (strcat "value found is "(vla-get-textstring att )))
       )
)

 

 

thank you sir, i will try to figure out where will i put you code on the lisp... very much help!

Share this post


Link to post
Share on other sites
BIGAL

Here is a start, I would recommend adding a check does block have attributes, use entmake better than command for text.

 

(while (setq obj (vlax-ename->vla-object (car(entsel "pick block"))))
  (foreach att (vlax-invoke obj 'getattributes)
       (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
       (setq txt(vla-get-textstring att ))
       )
  )
 (if (/= txt nil)
 (progn 
   (setq pt (getpoint "pick point for text"))
   (command "text" pt 2.5 90 txt)
 )
 )
)

Share this post


Link to post
Share on other sites
ktbjx
Here is a start, I would recommend adding a check does block have attributes, use entmake better than command for text.

 

(while (setq obj (vlax-ename->vla-object (car(entsel "pick block"))))
  (foreach att (vlax-invoke obj 'getattributes)
       (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
       (setq txt(vla-get-textstring att ))
       )
  )
 (if (/= txt nil)
 (progn 
   (setq pt (getpoint "pick point for text"))
   (command "text" pt 2.5 90 txt)
 )
 )
)

 

 

i did it yey! thank you sir! look that i came up with!

(defun c:attmt(/ obj att txt pt)
(while (setq obj (vlax-ename->vla-object (car(entsel "pick block"))))
  (foreach att (vlax-invoke obj 'getattributes)
       (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
       (setq txt(vla-get-textstring att ))
       )
  )
 (if (/= txt nil)
 (progn 
   (setq pt (getpoint "pick point for text"))
;    (command "text" pt 1.5 90 txt)
    (entmakex
   (list
     (cons 0   "MTEXT")         
     (cons 100 "AcDbEntity")          
     (cons 100 "AcDbMText")    
     (cons 10 pt)  
     (cons 40 1.5) 
     (cons 7 "Swis721 BlkOul BT")
     (cons 1 txt)
     
   )
       )
         
 )
 )
)
)

the font won't work though >.

Share this post


Link to post
Share on other sites
BIGAL

StyleName = "Standard" the cons 7 is probably looking for a style name not the font name. cons 7 "Standard"

 

Entmake will over ride the text height which is good because if you use Command "text" it has two variants with and without text height. The height must be taken into account or code can error. I test but make sure what my text style is set to.

Share this post


Link to post
Share on other sites
Tharwat

the font won't work though >.

 

     
(cons 7 "Swis721 BlkOul BT") [color="blue"];; delete or comment it[/color]
(cons 1 (strcat "{\\fSwis721 BdOul BT|b0|i0|c0|p82;" txt "}"))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×