Using lisp how do I check for NO viewports in paperspace.
(if ( ? )
(progn
( work )
)
)
|
Using lisp how do I check for NO viewports in paperspace.
(if ( ? )
(progn
( work )
)
)
Last edited by framedNlv; 2011-05-11 at 08:15 PM.
This may help:
Code:(foreach lay (layoutlist) (if (and (setq ss (ssget "_x" (list '(0 . "VIEWPORT") (cons 410 lay)))) (< 1 (setq i (sslength ss)))) ; <-- Ignore pviewport (prompt (strcat "\nFound " (rtos (1- i) 2 0) " on tab \"" lay "\"")) (prompt (strcat "\n** No viewports found on tab \"" lay "\" ** "))))
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Thanks,
I didn't want to check all tabs but the current so I started messing with what you wrote.
I guessing it was reading the paperspace viewport as one so I changed it to say "=" for the sslength and removed the for each.Code:(if (and (setq ss (ssget "_x" (list '(0 . "VIEWPORT") (cons 410 (getvar "ctab")))));changed to ctab (= 1 (setq i (sslength ss)))) ; <-- Ignore pviewport ;;changed to = 1 (alert "none");my work here )
These are on old R14 drawings and only have one viewport.
Somehow I was trying to use the not or nil and couldn't get anything to work.
Thanks again.
Chris
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
BlackBox_, just for academic purposes, you should know that it's highly inefficient to create multiple calls to ssget when you could just make one, step through the selection and manipulate lists.
Last edited by BlackBox; 2015-11-23 at 09:33 PM.
What are you talking about???
Maybe it's because I'm home, sitting on my couch after a kick-@$$ meal, but what about the code I posted is ineffective, or falls short of the OP's request?
To clarify, neither of the posts of code that I've made in this thread make more than a single selection set, and I have done no list/selection set manipulation... I'm simply checking for paper space viewports (other than the PViewport itself).
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
I found that the ssget method is not working well, when the viewports
are not fully zoomed out.
Therefore:
or betterCode:(defun c:DelLayouts (/ ~Tm LayoutsLst i Layout) (Setq ~Tm (getvar "TILEMODE")) (setvar "TILEMODE" 1) (setq LayoutsLst (layoutlist)) (setq i 0) (repeat (length LayoutsLst) (command "_.LAYOUT" "_S" (nth i LayoutsLst)) (command "_.PSPACE") (command "_.ZOOM" "_E") (setq i (1+ i)) ) (setq i 0) (repeat (length LayoutsLst) (setq Layout (nth i LayoutsLst)) (if (< (SSlength (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 Layout))) ) 2 ) (command "_.LAYOUT" "_D" Layout);The work is: to Delete Layout with no Viewports ) (setq i (1+ i)) ) ;(setvar "TILEMODE" ~Tm) (princ) )
Regards, HofCAD CSI.Code:(defun c:DelLayouts(/ doc ent Oke HasVp) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-layouts doc) (setq HasVp nil Oke nil ) (vlax-for ent (vla-get-block lay) (if (and Oke (eq (vla-get-objectname ent) "AcDbViewport") ) (setq HasVp T) (setq Oke T) ) ) (and (not HasVp) (if (not (eq "MODEL" (strcase (vla-get-Name lay)))) (vla-delete lay);The work is: to Delete Layout with no Viewports ) ) ) )
Last edited by hofcad; 2011-05-12 at 10:56 PM.
Here is a routine that creates a list of sublists with the assoc string being the layout name and subsequent viewport objects for each layout following.
Remember the first viewport in each layout (except model) is the layout itself.
Peter
Code:(defun C:ViewportList (/ lstOfSublists lstSublist objItem objLayout ) (vlax-for objLayout (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq lstSublist (list (vla-get-name objLayout))) (vlax-for objItem (vla-get-block objLayout) (if (= (vla-get-objectname objItem) "AcDbViewport") (setq lstSublist (cons objItem lstSublist)) ) ) (setq lstOfSublists (cons (reverse lstSublist) lstOfSublists)) ) (reverse lstOfSublists) )
AutomateCAD