Add suffix to Dimension text in block

Add suffix to Dimension text in block

jaggisingh003
Advocate Advocate
802 Views
4 Replies
Message 1 of 5

Add suffix to Dimension text in block

jaggisingh003
Advocate
Advocate

hello,.

i want a lisp to add suffix "(A)", "(B)", "(C)" to block Dimension text.

 

i found a code by lee mac for find replace text.
but it replace text in all blocks in drawing. 

Code  :-

 

(defun c:SDReplace ( / _StringSubst old new doc ) (vl-load-com)
;; © Lee Mac 2011

(defun _StringSubst ( new old str / i l ) (setq i 0 l (strlen new))
(while
(and
(< i (strlen str))
(setq i (vl-string-search old str i))
(setq str (vl-string-subst new old str i) i (+ i l))
)
)
str
)

(setq old (getstring t "\nFind What: "))
(setq new (getstring t "\nReplace With: "))

(vlax-for block
(vla-get-blocks
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
)
(if
(and
(eq :vlax-false (vla-get-isXref block))
(eq :vlax-false (vla-get-isLayout block))
)
(vlax-for obj block
(if (wcmatch (vla-get-objectname obj) "AcDb*Text")
(vla-put-TextString obj (_StringSubst new old (vla-get-TextString obj)))
)
)
)
)
(vla-regen doc acActiveViewport)
(princ)
)......

 

Please help for this code replace selected block Dimension Text only.

 

Sorry for my English  🙂 

 

 

0 Likes
803 Views
4 Replies
Replies (4)
Message 2 of 5

fkp7057
Advocate
Advocate

Hi,

 

@jaggisingh003  you dont need any code & .lsp file it can be done using Auto cad dimension style setting

refer below screen cast you will get idea how its work. hope it will help you. cheers...

 

Click on Accept solution if its solves your problem.

 

 
 
 
 
 
 
 
 
0 Likes
Message 3 of 5

jaggisingh003
Advocate
Advocate

Thanks, for this but this is not the Solution i want.

your block is used only one time in Drawing I have to using the same block in all drawing with different dimension and with different Suffix.  

 

0 Likes
Message 4 of 5

fkp7057
Advocate
Advocate

you can use this block as multiple time & if you are using same block in different-different drawing with another prefix-suffix you just need to update dimension style as per your requirement.

0 Likes
Message 5 of 5

ToanDN
Consultant
Consultant

Annotation 2019-12-24 105219.PNG.jpg

0 Likes