JADT Posted September 29, 2014 Share Posted September 29, 2014 I would like some help with maybe a lisp that would help with the following please. I would like to run a lisp on a drawing that would:- switch to paperspace lock all viewports zoom all layouts to extents make first layout current - the layout however will have been renamed so no longer original default name... save i will probably make a tool button for this on a palette so i can just click. Quote Link to comment Share on other sites More sharing options...
RobDraw Posted September 29, 2014 Share Posted September 29, 2014 There are many examples of LISP for this. Could you not find one with a search? You probably won't find one that does exactly what you want. But at least you will have a base to work from and with a little modification you should be good to go. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted September 29, 2014 Share Posted September 29, 2014 I moved your thread to the AutoLISP, Visual LISP & DCL Forum. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 30, 2014 Share Posted September 30, 2014 Try this ; goes through all layout tabs and zooms all ; By Alan H june 2011 (vl-load-com) (command "_.pspace") (setq curtab (getvar "Ctab")) (setq this_dwg (vlax-get-acad-object)) (foreach d (layoutlist) (setvar "CTAB" d) ;(vla-put-mspace this_dwg :vlax-false) (COMMAND "pSPACE") (command "zoom" "C" "400,277" 600) ) (setvar "ctab" curtab) (princ) and this one needs patching for goto 1st as part of above. Note Model is 0 1st layout is 1 (defun C:goto ( / alllayouts lay num) (setq num (getint "\nEnter tab number")) (setq alllayouts (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))) (SETQ LAYNUM 0) (vlax-for x alllayouts (Setq laynum (+ 1 laynum)) ) ;total number of layouts (if (> num laynum) (setq num (- laynum 1)) ) (vlax-for lay alllayouts (if (= num (vla-get-taborder lay)) (setvar "ctab" (vla-get-name lay)) ) ; if ) ; for ) ; defun (C:goto) Quote Link to comment Share on other sites More sharing options...
mostafa badran Posted September 30, 2014 Share Posted September 30, 2014 (edited) Perhaps this help . (defun c:test (/ lay ent) (vl-load-com) (vlax-for lay (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)) ) (if (eq :vlax-false (vla-get-modeltype lay)) (vlax-for ent (vla-get-block lay) (if (= (vla-get-objectname ent) "AcDbViewport") (vla-put-displaylocked ent :vlax-true) ) ) ) ) (lze) ) (defun lze (/ AC OT ) (setq ot (getvar 'CTAB) ac (vlax-get-acad-object) ) (foreach l (layoutlist) (setvar 'CTAB l) (vla-ZoomExtents ac) ) (setvar 'CTAB ot) (lsw) ) (defun lsw(/ aDoc) (setvar "TILEMODE" 1);thanks for ASMI on [url="http://www.cadtutor.net/forum/showthread.php?25524-Activating-any-layout-with-lisp&p=163492&viewfull=1#post163492"]cadtutor.net[/url] (vlax-for l(vla-get-Layouts (setq aDoc(vla-get-ActiveDocument (vlax-get-acad-object)))) (getkword (strcat"\nPress Spacebar for layout '" (vla-get-Name l) "' ")) (vla-put-ActiveLayout aDoc l) ); end vlax-for (princ "\n<<< No more layouts, goodbuy... >>> ") (command "qsave") (princ) ); end of c:lsw Edited October 1, 2014 by mostafa badran improve code Quote Link to comment Share on other sites More sharing options...
JADT Posted October 6, 2014 Author Share Posted October 6, 2014 Big Al & mostafa, thank you. that seems to do what I require. Not sure about the spacebar input instruction to invoke layout 1 if the lisp could just default to layout 1 without any required input that would be great. I will try and work through your lisps and learn what each part is doing and try to modify myself that's how i'm teaching myself at the moment... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 6, 2014 Share Posted October 6, 2014 Here is my version: (defun c:tidy ( / app doc idx lay lst sel ) (setq app (vlax-get-acad-object) doc (vla-get-activedocument app) ) (vlax-for obj (vla-get-layouts doc) (if (= :vlax-false (vla-get-modeltype obj)) (progn (setq lay (vla-get-name obj) lst (cons (cons (vla-get-taborder obj) lay) lst) ) (setvar 'ctab lay) (vla-put-mspace doc :vlax-false) (setq sel (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 lay)))) (repeat (setq idx (1- (sslength sel))) (vla-put-displaylocked (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) :vlax-true) ) (vla-zoomextents app) ) ) ) (setvar 'ctab (cdr (assoc 1 lst))) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
JADT Posted October 6, 2014 Author Share Posted October 6, 2014 All hail the Mac. Lee, thank you absolublinkinglutley bang on. Ta J Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 6, 2014 Share Posted October 6, 2014 You're welcome JADT, happy to help. 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.