Convert All vports in All Layouts from Polygonal to Rectangular

Convert All vports in All Layouts from Polygonal to Rectangular

danglar
Advocate Advocate
824 Views
2 Replies
Message 1 of 3

Convert All vports in All Layouts from Polygonal to Rectangular

danglar
Advocate
Advocate

I wrote a simple lisp to convert a single vport from poligonal form to rectangular:

 

(defun c:vpr ()
 (setvar "cmdecho" 0)
 (setq switch (command "_.pspace"))
 (setq selections (entsel "Select Polygonal VPort to convert to Rectangular: "))
 (command "vpclip" selections "d" )
 )

 

It works nice, but I need to convert a huge bunch of viewports at once...

Can you improve my programm in order to Convert All vports in All Layouts at once?

Any help will be very appreciated

0 Likes
Accepted solutions (1)
825 Views
2 Replies
Replies (2)
Message 2 of 3

phanaem
Collaborator
Collaborator
Accepted solution

The clipped status of a viewport is read only, so you cannot change it via ActiveX.

You cannot entmod a viewport, so you must relay on command.

 

(defun c:test (/ *error* acdoc cmd ss i e)
  (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
        cmd (getvar 'cmdecho))
  (vla-startundomark acdoc)
  (setvar 'cmdecho 0)
  
  (defun *error* (msg)
    (and
      msg
      (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*EXIT*"))
      (princ (strcat "\nError: " msg))
    )
    (setvar 'cmdecho cmd)
    (vla-endundomark acdoc)
    (princ)
  )
  
  (foreach lo (layoutlist)
    (setvar 'ctab lo)
    (vla-put-mspace acdoc :vlax-false)
    (if
      (setq ss (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 lo) '(-4 . ">") '(68 . 1))))
      (repeat (setq i (sslength ss))
        (setq e (ssname ss (setq i (1- i))))
        (if
          (= (logand 65536 (cdr (assoc 90 (entget e)))) 65536); or (assoc 340 (entget e)) ??? -> clipped viewport
          (command "_clip" e "_d")
        )
      )
    )
  )

  (*error* nil)
  (princ)
)
0 Likes
Message 3 of 3

danglar
Advocate
Advocate

Works Perfect! Thank You!

0 Likes