Jump to content

Get a Block TextString using VBA?


muck

Recommended Posts

Using AutoCAD VBA, Is it possable to access a text string in a block? I want to get a block textstring to change color or layer? Note, I am not taking about a block attribute.

I am trying to access a string of text that is in the block. I am interested in acessing

both the block definations and block references.

 

I am also interested in accessing Mtext and dimensions in a block.

Thank you,

Link to comment
Share on other sites

Here is a change linetype example shopuld be able to change the code to search for text and then change. You can call lisp from VBA

 

;(defun c:normblocks (/ adoc) 
 (vl-load-com) 
 (setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
 (vla-startundomark adoc) 
 (vlax-for block (vla-get-blocks adoc) 
   (if   (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) 
     (vlax-for   ent block 

(if  (= (vla-get-linetype ent ) "solid" ) 
(progn
(vla-put-linetype ent "Continuous")
(princ (vla-get-name block))
)
);_ end of if
   
  ) ;_ end of vlax-for 
     ) ;_ end of if 
   ) ;_ end of vlax-for 
 (vla-regen adoc acactiveviewport) 
 (vla-endundomark adoc) 
 (princ) 

 

 

try replacing (if (= (vla-get-linetype ent ) "solid" ) with (if (=(vla-get-text ent ) mytext ) not sure if ok this code was done by but met my needs.

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