Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
Posts: 82
Registered: ‎10-17-2008
Message 1 of 16 (1,281 Views)

Find and replace multileader text with LISP

1281 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*
Posts: 2,369
Registered: ‎11-24-2009
Message 2 of 16 (1,262 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*
Posts: 2,369
Registered: ‎11-24-2009
Message 3 of 16 (1,257 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
Posts: 82
Registered: ‎10-17-2008
Message 4 of 16 (1,243 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: 463
Registered: ‎08-25-2008
Message 5 of 16 (1,238 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*
Posts: 2,369
Registered: ‎11-24-2009
Message 6 of 16 (1,234 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 (972 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*
Posts: 2,369
Registered: ‎11-24-2009
Message 8 of 16 (960 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 (939 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 (937 Views)

Re: Find and replace multileader text with LISP

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

Here's the code.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community