jason_a Posted November 11, 2010 Share Posted November 11, 2010 I'm trying to create an ACAD2000 lisp routine that will print only Paperspace tabs. This is what I have so far: (defun c:Plt (/ ) (foreach layoutname (layoutlist ) (command "._layout" "set" layoutname ) (command "-plot" "yes" layoutname "\\\\sbserver\\Canon ir3235" "LETTER" "INCHES" "PORTRAIT" "NO" ;PLOT UPSIDE DOWN "LAYOUT" "1:1" "0.00,0.00" "YES" ;PLOT WITH PLOTSYTLES "MONOCHROME.CTB" "NO" ;PLOT WITH LINEWEIGHTS "NO" ;SCALE LINEWEIGHTS WITH PLOT SCALE "YES" ;PLOT PAPER SPACE LAST "NO" ;REMOVE HIDDEN LINES "NO" ;WRITE THE PLOT TO A FILE "NO" ;SAVE CHANGES TO LAYOUT "YES");PROCEED WITH PLOT ) (princ) ) It works BUT some of my AutoCad files incorporate the Model tab into the layout list and I don't want that. So to rectify the problem, i'd like to place a model tab exclusion string into the lisp code. I sourced this piece of code from the internet. It compiles an alphabetic layout tab order and removes the Model space tab from its list. How can I incorporate that piece of code into my existing routine? ;create list of layout tabs (in proper order) (defun layouttablist (/ lst) (vlax-map-collection (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) '(lambda (x) (setq lst (cons x lst)))) ;; sort in tab order (setq lst (vl-sort lst '(lambda (x y) (< (vla-get-taborder x) (vla-get-taborder y))))) ;; make list of names into strings remove Model space (setq lst (vl-remove "Model" (mapcar '(lambda (x)(vla-get-name x))lst))) ) Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2010 Share Posted November 11, 2010 You could just use something like: (vl-remove "Model" (layoutlist)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2010 Share Posted November 11, 2010 Alternatively, another possibility: (foreach layoutname (mapcar 'cdr (vl-sort ( (lambda ( / l n ) (vlax-for x (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object) ) ) (if (not (eq "MODEL" (strcase (setq n (vla-get-Name x))))) (setq l (cons (cons x n) l)) ) ) l ) ) (function (lambda ( a b ) (< (vla-get-TabOrder (car a)) (vla-get-TabOrder (car b))) ) ) ) ) ... ) Or, in Vanilla perhaps: (foreach layoutname ( (lambda ( dict / def l n ) (while (setq def (dictnext dict (null def))) (if (not (eq "MODEL" (strcase (setq n (cdr (assoc 1 (reverse def))))))) (setq l (cons n l)) ) ) (reverse l) ) (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT"))) ) ... ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 11, 2010 Share Posted November 11, 2010 You could just use something like: (vl-remove "Model" (layoutlist)) (layoutlist) doesn't include Model. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2010 Share Posted November 11, 2010 (layoutlist) doesn't include Model. Yeah, I didn't think so either - but the OP states that some of his files do include it. BUT some of my AutoCad files incorporate the Model tab into the layout list Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 11, 2010 Share Posted November 11, 2010 Yeah, I didn't think so either - but the OP states that some of his files do include it.Wild. Must be an freaky thing with older versions. Might have something to do with files that could have been created with r14 (before layouts existed). To answer the OP's question: Replace: (foreach layoutname (layoutlist ) With: (foreach layoutname (layouttablist) Quote Link to comment Share on other sites More sharing options...
jason_a Posted November 11, 2010 Author Share Posted November 11, 2010 So I tried replacing layoutlist with layouttablist and got the following: Command: (layouttablist) ; error: no function definition: LAYOUTTABLIST This is what I get when I simply use layoutlist in the offending drawing: Command: (layoutlist) ("Layout1" "Model") Mind you, if I use layoutlist in other drawings, it works fine and i'll get: Command: (layoutlist) ("Layout1") So I suspect something is up inside that specific offending drawing. A setting or switch i'm not aware of. I incorporated (vl-remove "Model" (layoutlist)) into the code but it didn't eliminate the model tab selection. (defun c:Plt (/ ) (foreach layoutname (layoutlist ) (vl-remove "Model" (layoutlist)) ;<--------------- (command "._layout" "set" layoutname ) (command "-plot" "yes" layoutname "etc etc...." Then I copied the following into my routine (defun c:Plt (/ ) ;(foreach layoutname (layoutlist ) (foreach layoutname (mapcar 'cdr (vl-sort ( (lambda ( / l n ) (vlax-for x (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object) ) ) (if (not (eq "MODEL" (strcase (setq n (vla-get-Name x))))) (setq l (cons (cons x n) l)) ) ) l ) ) (function (lambda ( a b ) (< (vla-get-TabOrder (car a)) (vla-get-TabOrder (car b))) ) ) ) ) (command "._layout" "set" layoutname ) (command "-plot" "yes" layoutname "etc etc...." and that does the trick. Hopefully I won't run into any other problems. Thanks for your help! I can now use this lisp file in conjunction with EZScriptpro and print the approx 400 drawings to complete my project. I didn't like Batch Plot Utility because it would open all the drawings and slow my computer down. With EZScriptpro, it opens a drawing, runs the lisp file, closes the drawing and continues the process. Thanks! Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 11, 2010 Share Posted November 11, 2010 The original isn't working because you didn't add the subroutine you posted to your code. Load it in AutoCAD and try it again. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2010 Share Posted November 11, 2010 I incorporated (vl-remove "Model" (layoutlist)) into the code but it didn't eliminate the model tab selection. (defun c:Plt (/ ) (foreach layoutname (layoutlist ) (vl-remove "Model" (layoutlist)) ;<--------------- (command "._layout" "set" layoutname ) (command "-plot" "yes" layoutname "etc etc...." This is because you incorporated it incorrectly: (defun c:Plt ( / ) (foreach layoutname [color=red][b](vl-remove "Model" (layoutlist))[/b][/color] (command "._layout" "set" layoutname) (command "-plot" "yes" layoutname "etc etc...." Quote Link to comment Share on other sites More sharing options...
jason_a Posted November 11, 2010 Author Share Posted November 11, 2010 Ah i see. I'll try that now, thank you. Quote Link to comment Share on other sites More sharing options...
jason_a Posted November 11, 2010 Author Share Posted November 11, 2010 Works great and thanks for the clarification. Lastly, now that you've provided two different ways to accomplish the same task, is one routine superior to the other? edit: Scratch the question. I see that one of them organizes the tabs. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 11, 2010 Share Posted November 11, 2010 You're welcome In most (but not all) cases, the more concise solution is usually quicker. Quote Link to comment Share on other sites More sharing options...
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.