See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Check for no viewports in paperspace?

  1. #1
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Check for no viewports in paperspace?

    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.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    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

  3. #3
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    Thanks,
    I didn't want to check all tabs but the current so I started messing with what you wrote.

    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
       )
    I guessing it was reading the paperspace viewport as one so I changed it to say "=" for the sslength and removed the for each.

    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

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    1

    Default Re: Check for no viewports in paperspace?

    Quote Originally Posted by FRAMEDNLV View Post
    Thanks,
    I didn't want to check all tabs but the current so I started messing with what you wrote.

    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
       )
    I guessing it was reading the paperspace viewport as one so I changed it to say "=" for the sslength and removed the for each.

    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

    Here's another (shorter) example:

    Code:
    (if
      (not
        (setq ss
               (ssget "_x"
                      (list '(0 . "VIEWPORT")
                            (cons 410 (getvar 'ctab))
                            '(-4 . "<NOT")
                            '(69 . 1)                                ; <-- Ignore pviewport 
                            '(-4 . "NOT>")
                            )
                      )
              )
        )
      ;; <-- Your code here
      )
    "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

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    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.

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    Quote Originally Posted by FRAMEDNLV View Post
    Using lisp how do I check for NO viewports in paperspace.
    Quote Originally Posted by RenderMan View Post
    Code:
    (if
      (not
        (setq ss
               (ssget "_x"
                      (list '(0 . "VIEWPORT")
                            (cons 410 (getvar 'ctab))
                            '(-4 . "<NOT")
                            '(69 . 1)                                ; <-- Ignore pviewport 
                            '(-4 . "NOT>")
                            )
                      )
              )
        )
      ;; <-- Your code here
      )
    Quote Originally Posted by alanjt View Post
    Mat, 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.
    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

  7. #7
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    Quote Originally Posted by RenderMan View Post
    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).
    I was referring to your first post (#2). You foreach through the return from (layoutlist) and make a ssget selection for each return layout.

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    Quote Originally Posted by alanjt View Post
    I was referring to your first post (#2). You foreach through the return from (layoutlist) and make a ssget selection for each return layout.
    Thanks for the clarification, Alan. I wasn't tracking the foreach preceding the ssget call (making the multiple calls you mentioned) before I replied.

    Only after that post did I find out the OP only wanted to query a single layout.

    Point taken.
    "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

  9. #9
    100 Club
    Join Date
    2005-09
    Posts
    111
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    Quote Originally Posted by FRAMEDNLV View Post
    Using lisp how do I check for NO viewports in paperspace.


    (if ( ? )
    (progn
    ( work )
    )
    )
    I found that the ssget method is not working well, when the viewports
    are not fully zoomed out.
    Therefore:
    Code:
    (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)
    )
    or better
    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
    	 )
        )
      )
    )
    Regards, HofCAD CSI.
    Last edited by hofcad; 2011-05-12 at 10:56 PM.

  10. #10
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Check for no viewports in paperspace?

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 9
    Last Post: 2013-04-12, 10:06 PM
  2. 2013: Line Scale in Viewports (Paperspace)
    By Darren Allen in forum AutoCAD General
    Replies: 8
    Last Post: 2012-10-03, 04:20 PM
  3. Paperspace Viewports
    By bowtle in forum AutoCAD General
    Replies: 1
    Last Post: 2008-10-16, 11:38 AM
  4. Viewports in Paperspace are missing their frames
    By UFO in forum AutoCAD General
    Replies: 4
    Last Post: 2007-05-22, 11:37 AM
  5. Paperspace viewports? 1:1 or 1/dwg scale
    By GreyHippo in forum AutoCAD General
    Replies: 23
    Last Post: 2005-04-20, 06:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •