View Full Version : A way to select a layout tab with a lisp
dfuehrer
2007-10-17, 09:02 PM
Hello everyone,
I am hoping that someone here has a solution for me! I would like to incorporate into a lisp the ability to select a specific named layout tab in any given drawing. The kicker here is that these tabs are not named consistantly.
They may be named "8.5 x 11" or "85x11" or "8 x 11", etc. You see what I am up against! Problem is there are hundreds of thes files in our database. The wildcard doesn't seem to work when using the LAYOUT command from the prompt so...
Anyone have a solution??
Thanks in advance!
Don
T.Willey
2007-10-17, 09:52 PM
See if this will work for you.
(defun c:Test (/ ActDoc LoName)
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for lo (vla-get-Layouts ActDoc)
(setq LoName (vla-get-Name lo))
(if
(and
(vl-string-search "8" LoName)
(vl-string-search "5" LoName)
(vl-string-search "11" LoName)
)
(vla-put-ActiveLayout ActDoc lo)
)
)
(princ)
)
dfuehrer
2007-10-17, 10:25 PM
Hi Tim,
Thanks! It does seem to work. Exactly what I was looking for!
Don
T.Willey
2007-10-17, 11:46 PM
Hi Tim,
Thanks! It does seem to work. Exactly what I was looking for!
Don
You're welcome Don. You understand what it's doing right? So that if it needs to be fixed, or it switches to a layout you don't think it should, you can fix it.
dfuehrer
2007-10-18, 03:21 PM
Yes, I can see how it is accomplishing the selection of the layout tab. Thanks again!
CADmium
2007-10-19, 08:24 AM
a function with wcmatch to use wildcards :
(defun c:GOTOLAYOUT(/ LAYOUTS PATTERN KWORD)
(setq LAYOUTS(mapcar 'strcase(cons "MODEL" (layoutlist))))
(if(and(setq PATTERN(strcase(getstring "Layoutname (with wildcards):")))
(/= PATTERN "")
)
(progn
(setq LAYOUTS(vl-remove-if-not '(lambda(X)(wcmatch X PATTERN))LAYOUTS))
(setvar "CTAB" (car LAYOUTS))
(princ (strcat "\n" (itoa(length LAYOUTS))" layouts found."))
(setq LAYOUTS(cdr LAYOUTS))
(initget "Yes No")
(while(and LAYOUTS
(or(=(setq KWORD (getkword "\rNext layout ? (Yes / No)<Yes>"))"Yes")
(not KWORD)
)
)
(setvar "CTAB" (car LAYOUTS))
(setq LAYOUTS(cdr LAYOUTS))
(initget "Yes No")
)
)
)
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.