The Courage Dog Posted July 15, 2009 Posted July 15, 2009 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. Quote
Commandobill Posted July 15, 2009 Posted July 15, 2009 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))) Quote
The Courage Dog Posted July 16, 2009 Author Posted July 16, 2009 wow, i tried your code, what a great. thanks mr. commandobill:) Quote
Commandobill Posted July 16, 2009 Posted July 16, 2009 No problem! Hope everything works out well for you. Quote
The Courage Dog Posted August 10, 2009 Author Posted August 10, 2009 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. Quote
Commandobill Posted August 10, 2009 Posted August 10, 2009 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. Quote
The Courage Dog Posted August 11, 2009 Author Posted August 11, 2009 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. Quote
Commandobill Posted August 11, 2009 Posted August 11, 2009 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))) ) Quote
The Courage Dog Posted August 11, 2009 Author Posted August 11, 2009 your new code works perfect now. thanks bill. Quote
Recommended Posts
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.