• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Valued Contributor
    Posts: 67
    Registered: ‎10-17-2008

    Find and replace multileader text with LISP

    763 Views, 14 Replies
    01-25-2012 09:15 AM

    I'm looking for a lisp routine that can find and replace multileader text.

    I want to replace "T." with "T+" and "B." with "B+".

    All the multileaders are on layers with a suffix of "-elev".

    Any help will be greatly appreciated.

     

    Thanks in advance,

    Larry

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: Find and replace multileader text with LISP

    01-26-2012 03:07 AM in reply to: bdsmls

    bdsmls wrote:

    I'm looking for a lisp routine that can find and replace multileader text.

    I want to replace "T." with "T+" and "B." with "B+".

    All the multileaders are on layers with a suffix of "-elev".

    Any help will be greatly appreciated.

     

    Thanks in advance,

    Larry


    command:  _find
         
    settings....
    Text types
    Dimension/Leader text

     
    Why the need for lisp codes?

     

    Anyway, since i'm replying.

     

    (defun c:REpME  (/ sel e)
          (setq sel (ssget "_X" '((0 . "MULTILEADER")(8 . "*-elev"))))
          (repeat (sslength sel)
                (setq e (vlax-ename->vla-object (ssname sel 0)))
                (vla-put-textstring
                      e
                      (vl-string-translate
                            "B.T."
                            "B+T+"
                            (vla-get-textstring e)))
                (ssdel (ssname sel 0) sel)
                )
          )

     

    HTH

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: Find and replace multileader text with LISP

    01-26-2012 05:14 AM in reply to: pbejse

    Scratch the previous post

     

    This is more specific:

     

    (defun c:REpME  (/ sel e)
          (if (setq sel (ssget '((0 . "MULTILEADER")(8 . "*-elev"))))
    	      (repeat (sslength sel)
    	            (setq e (vlax-ename->vla-object (ssname sel 0))
    	                   str (vla-get-textstring e))
    	            (if (setq f	 
    		            (cond
    		            	((wcmatch str "*B.*") (list "B." "B+"))
    			        ((wcmatch str "*T.*") (list "T." "T+"))))
    			(vla-put-textstring e
    	                (vl-string-subst (cadr f)(car f) str) )
    	                		
    	                                )
    	            (ssdel (ssname sel 0) sel)
    	            )
              )
              (princ)
          )

     

     

    Please use plain text.
    Valued Contributor
    Posts: 67
    Registered: ‎10-17-2008

    Re: Find and replace multileader text with LISP

    01-26-2012 09:34 AM in reply to: bdsmls

    That's what i was looking for. Thanks for your help.

     

    Larry

    Please use plain text.
    Mentor
    alanjt_
    Posts: 218
    Registered: ‎08-25-2008

    Re: Find and replace multileader text with LISP

    01-26-2012 01:19 PM in reply to: pbejse

    @pbejse: FYI, wcmatch IS case sensitive.

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: Find and replace multileader text with LISP

    01-26-2012 09:27 PM in reply to: alanjt_

    You are absolutely right.. my mistake :smileywink:

     

    Thanks Alanjt.....

    Please use plain text.
    Member
    bbarkman.jedson
    Posts: 5
    Registered: ‎05-04-2011

    Re: Find and replace multileader text with LISP

    10-08-2012 12:58 PM in reply to: bdsmls

    Would this work if a block with an attribute is embedded in the multileader?

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: Find and replace multileader text with LISP

    10-08-2012 08:14 PM in reply to: bbarkman.jedson

    bbarkman.jedson wrote:

    Would this work if a block with an attribute is embedded in the multileader?


    Yes i think its possible, what do you have in mind? 

    Please use plain text.
    Member
    bbarkman.jedson
    Posts: 5
    Registered: ‎05-04-2011

    Re: Find and replace multileader text with LISP

    10-09-2012 06:12 AM in reply to: pbejse
    Our revision tag is a block embedded in a multileader with the one attribute (REVNUM). I am prompting the user for the current revision letter/number (so the routine knows which values to look for) and the desired revision. I'd like to check the current value from the user against what's in the multileader. If there's a match, change it. If not, do nothing. In the same routine I'm also looking at regular blocks via the attribute name. That way if a block or multileader with that block is inserted they all get checked. When the attribute tag name is found the routine proceeds accordingly. This works fine with regular blocks. The only thing missing is the "if" action for multileaders. They get changed no matter what, which means a revision tag could be altered when it shouldn't. The current code is attached. Much of it was provided by Lee McDonnell.
    Please use plain text.
    Member
    bbarkman.jedson
    Posts: 5
    Registered: ‎05-04-2011

    Re: Find and replace multileader text with LISP

    10-09-2012 06:14 AM in reply to: bdsmls

    Here's the code.

    Please use plain text.