DavidP Posted 7 hours ago Posted 7 hours ago 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 Quote
Paul Li Posted 7 hours ago Posted 7 hours ago 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))) Quote
DavidP Posted 6 hours ago Author Posted 6 hours ago 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"))) ) Quote
Paul Li Posted 5 hours ago Posted 5 hours ago if you're only looking for true rectangular vports then testing for the dxf 340 is the best way to filter that out. Quote
DavidP Posted 5 hours ago Author Posted 5 hours ago Here is how the codes line up between all the view ports: Quote
Paul Li Posted 5 hours ago Posted 5 hours ago so you now know how to filter out the selection of a "true view port"? Quote
mhupp Posted 4 hours ago Posted 4 hours ago if your trying to select all Paperspace viewports at once. this filters all viewports that are not in model or the first (paperspace) (defun C:CLV () (C:CollectLayoutViewports)) (defun C:CollectLayoutViewports (/ ss) (if (not (setq ss (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (410 . "Model") (-4 . "!=") (69 . 1) (-4 . ">") (68 . 0)))) (princ "\nNo Active Paperspace Viewports Found") (princ (strcat "\n" (sslength ss) " Viewports Found")) ) ss ) Quote
Paul Li Posted 3 hours ago Posted 3 hours ago @mhupp unfortunately this ssget filter in autocad returns nothing: (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (410 . "Model") (-4 . "!=")(-4 . ">") )) Quote
DavidP Posted 2 hours ago Author Posted 2 hours ago I also believe some of the flags change as you move to different layouts/ change the zoom scale or move view port off screen..(I am getting inconstant result between drawings an auto-cad sessions.) I have a lisp to report the result to a text file but I been having issues posting posting. Quote
DavidP Posted 1 hour ago Author Posted 1 hour ago Code 68 and 69 is not consistent and when you first open a drawing most of these codes show 0 for a value... When you switch to the each of the layouts the value updates. So for now looping through the layouts and zooming extents appears to solve the issue. Then I'm just filtering for 69 > 1.. still a bit confused. Also these values in some case are -1 but still valid viewports and I run a second time and changes to positive value.. Still not 100% sure of what's going on. Quote
Paul Li Posted 1 hour ago Posted 1 hour ago @DavidP Yes, you do need to activate each layout in order for the vports to come alive. So looping through them is a good way to deal with this. Quote
BIGAL Posted 55 minutes ago Posted 55 minutes ago (edited) Just a comment Bricscad sometimes does not support the "(( make a list method. so this does work and I added get for current layout, in case have multi viewports in a layout. You could loop through the layouts rather than getting all. If make a list of properties then have the layout name. Having problems post in <> get error message finally got it. A test (sslength (setq ss (ssget "_X" (list (cons 0 "VIEWPORT") (cons 67 1) (cons -4 "/=") (cons 69 1)(cons 410 (getvar 'ctab)))))) Edited 48 minutes ago by BIGAL 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.