Jump to content

Recommended Posts

Posted

I'm trying to select all the true view port in each layout but I'm running into issues. There are more view ports in the drawing than what's visible to the user(not sure why this is as I only create one single view port in each layout).  So I need to filter for the actual view ports.

(defun c:CollectLayoutViewports (/ ss i ent ed layout number status pt items counts item)
  (setq items nil
        counts nil
        ss (ssget "_X" '((0 . "VIEWPORT") (67 . 1)))
  )
  (princ (strcat "\nSelection count: " (if ss (itoa (sslength ss)) "0")))
  (if ss
    (progn
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i)
              ed (entget ent)
              layout (cdr (assoc 410 ed))
              number (cdr (assoc 69 ed))
              status (cdr (assoc 68 ed))
              pt (cdr (assoc 10 ed))
        )
        (if (and layout
         (/= (strcase layout) "MODEL")
         (> number 1)
         (> status 0))      
          (progn
            (setq items (cons ent items))
          )
        )
        (setq i (+ i 1))
      )
    )
  )

  items

)

is there a DXF code I can filter by or any other suggestion...

 

ViewPortTest.dwg

Posted

Try this selection filter which should remove the paperspace object itself which is also considered as a vport

(ssget "_X" '((0 . "VIEWPORT") (67 . 1) (-4 . "/=") (69 . 1)))

Posted
32 minutes ago, Paul Li said:

Try this selection filter which should remove the paperspace object itself which is also considered as a vport

(ssget "_X" '((0 . "VIEWPORT") (67 . 1) (-4 . "/=") (69 . 1)))

That didn't work but I notice some have code 340,  other don't (Clipping boundary) so filtering post ssget worked... Just not exactly sure this true in every case.

(defun c:CollectLayoutViewports (/ ss i ent ed layout number status pt items counts item)
  (setq items nil
        ss (ssget "_X" '((0 . "VIEWPORT") (67 . 1)))
  )
  (princ (strcat "\nSelection count: " (if ss (itoa (sslength ss)) "0")))
  (if ss
    (progn
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i)
              ed (entget ent)
              layout (cdr (assoc 410 ed))
        )
        (if (and layout (/= (strcase layout) "MODEL") (assoc 340 ed))        
            (setq items (cons ent items))
        )
        (setq i (+ i 1))
      )
    )
  )
  (princ (strcat "\nResult count: " (if items (itoa (length items)) "0")))
)

 

Posted

if you're only looking for true rectangular vports then testing for the dxf 340 is the best way to filter that out.

Posted

Here is how the codes line up between all the view ports:

Viewports.jpg

Posted

so you now know how to filter out the selection of a "true view port"?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...