mhupp Posted yesterday at 09:19 PM Posted yesterday at 09:19 PM Another tip if your setting multiple variables. You can handle them with 4 lines of code. (defun C:lnze (/ lyt) ;(setq oldEcho (getvar "CMDECHO") ; oldNOMUTT (getvar "NOMUTT") ; lyt (getvar "CTAB") ;) (setq vars '(cmdecho nomutt ctab) ;list of variables as many as you want. vals (mapcar 'getvar vars) ;store old values to a list ) ;(setvar 'CMDECHO 0) ;(setvar 'NOMUTT 1) (mapcar 'setvar vars '(0 1)) ;this sets cmdecho 0 and nomutt 1, stops at short list so ctab isn't changed. (vl-catch-all-apply '(lambda () (foreach lay (layoutlist) (setvar 'CTAB lay) (setvar 'CVPORT 1) (vl-cmdf "_.ZOOM" "_E") ) ) ) ;(setvar "CTAB" lyt) ;(setvar "CMDECHO" oldEcho) ;(setvar "NOMUTT" oldNOMUTT) (mapcar 'setvar vars vals) ;restore old values (princ) ) Quote
Paul Li Posted yesterday at 09:47 PM Posted yesterday at 09:47 PM 38 minutes ago, ronjonp said: Side topic but I've found that this: (setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1)))) Does not work with layouts that are not initialized. CAB at TheSwamp put this together many moons ago and it's been solid ( don't remember what the function was originally named ) (defun rjp-getvports (/ a b c lst ss) (if (setq ss (ssget "_X" '((0 . "VIEWPORT")))) (progn (foreach e (mapcar 'cadr (ssnamex ss)) ;;Paper space block (if (and (setq a (cdr (assoc 330 (entget e)))) ;;Layout (setq b (cdr (assoc 340 (entget a)))) ;;Viewport not wanted (setq c (cdr (assoc 331 (entget b)))) ) (or (equal c e) (setq lst (cons (list e (cdr (assoc 71 (entget b)))) lst))) ) ) ) ) ;;Sort the list by taborder L 2 R (mapcar 'car (vl-sort lst (function (lambda (x y) (< (cadr x) (cadr y)))))) ) @ronjonp When I first open the sample TrueViewports.dwg I shared in a previous post which defaults to Layout2 and I run (length (rjp-getvports)) I get 7. Even after initializing by clicking on Layout1. I still get 7. But after clicking on Layout2 when I run @DavidP code I get 6: (sslength(setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "<>") (69 . 1) (410 . "~Model"))))) Likewise when I run my code I posted earlier I also get 6: (sslength (ssget "_X" '((0 . "VIEWPORT") (67 . 1) (-4 . "/=") (69 . 1)))) I think mine & @DavidP code is similar. But what I don't see is whether @DavidP code is filtering out something more than compared to mine. Quote
BIGAL Posted 23 hours ago Posted 23 hours ago Just a comment using Bricscad only finds. D05 (sslength (ssget "_X" '((0 . "VIEWPORT") (67 . 1) (-4 . "/=") (69 . 1)))) returns 4 D03 = 4 D05 (sslength (setq ss (ssget "_X" (list (cons 0 "VIEWPORT") (cons 410 (getvar 'ctab)))))) returns 1 ie no normal viewports D03 = 2 a pspace and 1 viewport The order of SS is Viewport...Viewport Pspace may be different in Acad. I copied viewports for testing. Then erased one by one using (ssname ss X) can not erase pspace of course. 1 Quote
DavidP Posted 20 hours ago Author Posted 20 hours ago 3 hours ago, Paul Li said: @ronjonp When I first open the sample TrueViewports.dwg I shared in a previous post which defaults to Layout2 and I run (length (rjp-getvports)) I get 7. Even after initializing by clicking on Layout1. I still get 7. But after clicking on Layout2 when I run @DavidP code I get 6: (sslength(setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "<>") (69 . 1) (410 . "~Model"))))) Likewise when I run my code I posted earlier I also get 6: (sslength (ssget "_X" '((0 . "VIEWPORT") (67 . 1) (-4 . "/=") (69 . 1)))) I think mine & @DavidP code is similar. But what I don't see is whether @DavidP code is filtering out something more than compared to mine. I assuming "<>" and "/n" filter produce the same result as they both mean "not equal" (assuming lisp supports both syntax) Filter 410 . "~Model" may depend whether you have model space view ports or not. If you omit it and have no view ports in model space then the result should be the same. Regarding the codes I don't believe they are consistent, I did notice if its off screen we get -1 but not always but I haven't done enough testing to come to a conclusion. Looping through the layouts is the only thing I found that makes the codes predictable. I may test in BricsCad the morning to see how it behaves (if it supports the code as is). Quote
Paul Li Posted 15 hours ago Posted 15 hours ago FYI: my (67 . 1) filters out model space vports so only paper space vports will be selected. 1 Quote
DavidP Posted 9 hours ago Author Posted 9 hours ago BricsCAD reports the correct number of view-ports without requiring looping through the layouts first. Quote
SLW210 Posted 8 hours ago Posted 8 hours ago I have a Zoom Extents in Modelspace and Zooms Extents, then .9x in all layouts, it helps with the offset AutoCAD puts on some drawings when opening them, plus works for finding odd paperspace items, zooms just a little more to show the edges. Still trying to determine what is wrong with Lee Mac VPOUTLINE LISP? Are you looking for a count of true viewports? I have a LISP that gives this report of true viewports in all layouts, as well as places a border in modelspace and creates/checks for my viewport layer. ====================================== AutoVPBrdr REPORT ====================================== True layout viewports: 5 Viewport layer assignments: 5 Layer assignment failures: 0 Modelspace borders created: 5 Viewports skipped: 0 -------------------------------------- Layer: Viewport Color: 45 Plot: OFF ====================================== It only places a border for a viewport referencing Top/Plan view. 1 1 Quote
mhupp Posted 7 hours ago Posted 7 hours ago (edited) 7 hours ago, Paul Li said: FYI: my (67 . 1) filters out model space vports so only paper space vports will be selected. Yeah fig so just left 410 in there to be safe. Edited 7 hours ago by mhupp Quote
ronjonp Posted 6 hours ago Posted 6 hours ago Here's another without command calls: (defun c:zal (/ a d c tabs) ;; RJP » 2020-07-08 (setq c (getvar 'ctab)) (vlax-for x (vla-get-layouts (setq d (vla-get-activedocument (setq a (vlax-get-acad-object))))) (setq tabs (cons (list (vla-get-name x) (vla-get-taborder x)) tabs)) ) ;; The sort makes sure that the tabs step left to right (foreach x (cdr (vl-sort tabs '(lambda (r j) (< (cadr r) (cadr j))))) (setvar 'ctab (car x)) (vlax-put d 'mspace 0) (vla-zoomextents a) ) (setvar 'ctab c) (princ) ) 1 Quote
Steven P Posted 1 hour ago Posted 1 hour ago 7 hours ago, SLW210 said: I have a Zoom Extents in Modelspace and Zooms Extents, then .9x in all layouts, it helps with the offset AutoCAD puts on some drawings when opening them, plus works for finding odd paperspace items, zooms just a little more to show the edges. These are ones I use: To record the current zoom: (setq currentzoom (list (getvar 'viewctr) (getvar 'viewsize))) .. zoom as you want And this returns you to where you were. (vla-ZoomCenter (vlax-get-acad-object) (vlax-3d-point (car currentzoom)) (cadr currentzoom)) Never tried with viewports but some ssget types need the entities to be selected to be in view, maybe viewports are the same 1 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.