How to select everything in the current view ?

Hi, I'm trying to make a "plan" command that zooms to the selected object at the new ucs or if nothing is selected it zooms to the current view but at the new ucs. Ie. It does not zoom to extents.

I figured If I could use an ssget command for everything in the view, I could use them to zoom to. The question is though, how do I ssget only everything int the current view ? (or is there a better way ?)

Comments

  • I don't understand what you're trying to do, but to select everything in the current view you can use the VIEWCTR and VIEWSIZE variables to calculate the coordinates of two opposite corners of the screen, and then use (ssget point1 point2) to select everything in a window or crossing between those points.
  • Thanks. I think this answers my question.
    I can use
    (getvar "viewctr") and (getvar "viewsize") to get the (ssget point1 point2). Just like you said. I'll post my code when I am finished so you can see what I am trying to do.
  • DFLY
    edited December 2022

    I don't understand what you're trying to do, but to select everything in the current view you can use the VIEWCTR and VIEWSIZE variables to calculate the coordinates of two opposite corners of the screen, and then use (ssget point1 point2) to select everything in a window or crossing between those points.

    Well with your helpful advice, I finally finished my code:
    (defun c:pplan ()
    (setq selected nil)
    (setq selected (ssget "I"))
    (if selected
    	(progn
    	    (command "plan" "")
    		(sssetfirst nil selected)
    		(command "zoom" "object" ))
    	(progn 
    		(command "circle" (getvar "viewctr") (/ (getvar "viewsize") 2))
    		(command "plan" "")
    		(command "zoom" "object" "last" "")
    		(command "delete"	"object"	"last" "")
    		)
    )
    	
    
    
    
    )