Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

Find and replace multileader text with LISP

1576 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,502
Registered: ‎11-24-2009
Message 2 of 16 (1,557 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,502
Registered: ‎11-24-2009
Message 3 of 16 (1,552 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: 88
Registered: ‎10-17-2008
Message 4 of 16 (1,538 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: 483
Registered: ‎08-25-2008
Message 5 of 16 (1,533 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,502
Registered: ‎11-24-2009
Message 6 of 16 (1,529 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.....

Contributor
bbarkman.jedson
Posts: 14
Registered: ‎05-04-2011
Message 7 of 16 (1,267 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,502
Registered: ‎11-24-2009
Message 8 of 16 (1,255 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? 

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

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 Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!