Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
bdsmls
Posts: 85
Registered: ‎10-17-2008
Message 1 of 16 (1,480 Views)

Find and replace multileader text with LISP

1480 Views, 15 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

*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 2 of 16 (1,461 Views)

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

*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 3 of 16 (1,456 Views)

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

 

 

Valued Contributor
bdsmls
Posts: 85
Registered: ‎10-17-2008
Message 4 of 16 (1,442 Views)

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

Valued Mentor
alanjt_
Posts: 480
Registered: ‎08-25-2008
Message 5 of 16 (1,437 Views)

Re: Find and replace multileader text with LISP

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

@pbejse: FYI, wcmatch IS case sensitive.

*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 6 of 16 (1,433 Views)

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

Active Member
bbarkman.jedson
Posts: 9
Registered: ‎05-04-2011
Message 7 of 16 (1,171 Views)

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?

*Expert Elite*
pbejse
Posts: 2,467
Registered: ‎11-24-2009
Message 8 of 16 (1,159 Views)

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? 

Active Member
bbarkman.jedson
Posts: 9
Registered: ‎05-04-2011
Message 9 of 16 (1,138 Views)

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.
Active Member
bbarkman.jedson
Posts: 9
Registered: ‎05-04-2011
Message 10 of 16 (1,136 Views)

Re: Find and replace multileader text with LISP

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

Here's the code.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.