Jump to content

Sheet filename same as Layout name


Recommended Posts

Posted

HI, is there a LISP routine that when you save a drawing it will automatically create a Layout with the same filename of the drawing & delete if there are more than one layout? (e.g. if the Sheet filename is A-001.dwg, the layout name will be A-001 as well. Instead of typing it will automatically rename the existing Layout name. In that way everytime you SAVEAS the drawing it will automatically do the same to the Layout name). :(

 

In our office CAD standard we keep one (1) Layout only for every Sheet file. What ever the Sheet filename is same as Layout name as well.

 

Your help are highly appreciated.

Thanks in advance.

Posted

You could use something like this in with some code for saveas...

 

(vla-put-name
 (vla-item
   (vla-get-layouts
     (vla-get-activedocument
   (vlax-get-acad-object))) 0) (substr (setq dwgn (getvar "dwgname")) 1 (- (strlen dwgn) 4)))

Posted

wow, i tried your code, what a great.

thanks mr. commandobill:)

Posted

No problem! Hope everything works out well for you.

  • 4 weeks later...
Posted

HI, there are times the code if working perfect, i mean it renaming the layout as per the drawing name. But there are times also it doesn't rename the layout, the message appearing on the command prompt is: Command: (load "rename-layout") ; error: Automation Error. Cannot rename the Model layout.. :(

 

thanks.

 

 

Posted

well i'd have to see your code but i would add a check to see if the layout you are trying to change is the model tab before running the rest of the code.

Posted

whether i'm in model tab or not, in modelspace or in papespace there are times that it doesn't work at all. :(

 

here's the code:

 

(vla-put-name

(vla-item

(vla-get-layouts

(vla-get-activedocument

(vlax-get-acad-object))) 0) (substr (setq dwgn (getvar "dwgname")) 1 (- (strlen dwgn) 4)))

 

it is the same code you have sent to me.

 

thanks for you time commandobill.

Posted

Like i said, I think what you need is a simple check to see if the tab you are trying to change is model or not. Something like this should suffice.

(defun c:rname ( / lay layo dwgn)
 (setq layo (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))))
 (if (= (vla-get-name (setq lay (vla-item layo 0))) "Model")
   (setq lay (vla-item layo 1)))
 (vla-put-name lay (substr (setq dwgn (getvar "dwgname")) 1 (- (strlen dwgn) 4)))
 )

Posted

your new code works perfect now.

thanks bill. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...