Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
bdcurry
Posts: 7
Registered: ‎10-03-2012
Message 11 of 17 (233 Views)

Re: naming a single layout tab to match the file name

10-11-2012 07:06 AM in reply to: pbejse

I am unable to get it to work, probably because im pretty new to Autolisp. Can i get more direction?

Thanks

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 12 of 17 (222 Views)

Re: naming a single layout tab to match the file name

10-11-2012 06:19 PM in reply to: bdcurry

bdcurry wrote:

I am unable to get it to work, probably because im pretty new to Autolisp. Can i get more direction?

Thanks


If you can tell us whats happening when you say unable to get it work. and it wouldnt work for text/mtext.

whats the error message if any?

 


As i explained from the previous post, there are strings that are considered invalid characters  "<>/\":;?*|,=`" for layout name

 

Mtext usually have the "\\P" , code for new line. you probably didnt notice the error message after you click on a text/mtext with invalid characters. it would say at the command prompt 

 

The following characters are not valid in layout names:  <>/\":;?*|,=`

 

Is that whats happening on your case? If not the, post a sample drawing and we'll figure out together

 

Help us help you......

 

 

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 13 of 17 (216 Views)

Re: naming a single layout tab to match the file name

10-11-2012 08:20 PM in reply to: pbejse

A quick mod [not tested]

 

(defun C:RTT (/ str)				; = Rename Tab to match Text
  (if (and  (/= (getvar 'ctab) "Model")
           (setq str (cdr (assoc 1 (reverse
	    (entget (car (nentsel
		  "\nSelect Text/Mtext/Attribute to change Layout Tab name to its content: "
		))))))))
	   (progn
	     (foreach kk '("\\P" "<" ">" "/" "\\" ":" ";" "?" "`*" "|" "," "=" "``")
               (while (vl-string-search kk str)
		(setq str (vl-string-subst (if (eq kk "\\P") " " "") kk str))
		))   
    		(command "_.layout" "_rename" (getvar 'ctab) str)		
    		)
    (prompt "\nCannot rename Model space tab.") 
  )
  (princ)
)

 

Active Member
bdcurry
Posts: 7
Registered: ‎10-03-2012
Message 14 of 17 (205 Views)

Re: naming a single layout tab to match the file name

10-12-2012 07:41 AM in reply to: pbejse

Ok the problem is that my Attributed block has multiple lines and it only renames the layout with one line..

Example..."Chilled Beam Cooling Water Diagram" is the full title

Each part of the title is didvided like this in the block...

Sheet title 1 = Chilled Beam

Sheet title 2  = Cooling Water

Sheet Tile 3 = Diagram

When i select the block it only renames the layout with "Chilled Beam"

or if i click "Cooling Water" it will rename the layout "Cooling Water" and so on...it will only read one line of the block.

I need it to read all three lines of the block and rename accordingly. Is there a way to have it rename it by the Tag or Prompt within the block? (fyi most on my blocks will have 5-7 lines of info)

 

i just tested the text/mtext title and it is working with the new lisp you sent above. Thanks!

 

I have atttached an example for the block.

 

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 15 of 17 (202 Views)

Re: naming a single layout tab to match the file name

10-12-2012 08:14 AM in reply to: bdcurry

bdcurry wrote:

Ok the problem is that my Attributed block has multiple lines and it only renames the layout with one line..

Example..."Chilled Beam Cooling Water Diagram" is the full title

Each part of the title is didvided like this in the block...

Sheet title 1 = Chilled Beam

Sheet title 2  = Cooling Water

Sheet Tile 3 = Diagram

When i select the block it only renames the layout with "Chilled Beam"

or if i click "Cooling Water" it will rename the layout "Cooling Water" and so on...it will only read one line of the block.

I need it to read all three lines of the block and rename accordingly. Is there a way to have it rename it by the Tag or Prompt within the block? (fyi most on my blocks will have 5-7 lines of info)

 

i just tested the text/mtext title and it is working with the new lisp you sent above. Thanks!

 

 


Kudos to Kent Cooper, It was really his idea.  :smileyhappy:

 

As for your request, i can think of a couple ways to do that.  easiest way is to use TAG names but it would be specific to a particular block. perhaps a prompt would be better .. we'll see, but it will have to wait till tomorrow .

 

Cheers

 

*Expert Elite*
pbejse
Posts: 2,500
Registered: ‎11-24-2009
Message 16 of 17 (183 Views)

Re: naming a single layout tab to match the file name

10-14-2012 12:36 AM in reply to: pbejse

I thought about this and made some test codes. I believe the best way to deal with attributes is to use a listbox. That way you can select the strings you want to use as layout name. But only if you select an  attribute.

 

The TAG reference is a good idea,but i would prefer to make the code generic .

 

usage:

command: RTT

 

If selected entity is an attribute this will appear

 

strings.jpg

 

 

HTH

 

 

Active Member
bdcurry
Posts: 7
Registered: ‎10-03-2012
Message 17 of 17 (167 Views)

Re: naming a single layout tab to match the file name

10-15-2012 07:40 AM in reply to: pbejse

Works Perfect!!!

 

Thank you all for your work in solving this for me.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

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