Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
88 Posts
0 Kudos
Registered: ‎10-17-2008
Post 1 of 16

Find and replace multileader text with LISP

1679 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*
2,535 Posts
306 Kudos
Registered: ‎11-24-2009
Post 2 of 16

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*
2,535 Posts
306 Kudos
Registered: ‎11-24-2009
Post 3 of 16

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
88 Posts
0 Kudos
Registered: ‎10-17-2008
Post 4 of 16

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
489 Posts
51 Kudos
Registered: ‎08-25-2008
Post 5 of 16

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*
2,535 Posts
306 Kudos
Registered: ‎11-24-2009
Post 6 of 16

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

Contributor
18 Posts
1 Kudo
Registered: ‎05-04-2011
Post 7 of 16

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*
2,535 Posts
306 Kudos
Registered: ‎11-24-2009
Post 8 of 16

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? 

Contributor
18 Posts
1 Kudo
Registered: ‎05-04-2011
Post 9 of 16

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.
Contributor
18 Posts
1 Kudo
Registered: ‎05-04-2011
Post 10 of 16

Re: Find and replace multileader text with LISP

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

Here's the code.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!