Originally Posted by
Tom Beauford
Why not save model space views instead of drawing rectangles? Then set view 1 current in viewport 1, view 2 current in viewport 2…
You could also zoom object and select a rectangle for each viewport.
Paper Space has been around more that the 20+ years I've been doing this, so I've never attempted a Model Space view. Concept of "1:500 viewports at A1 in my model" escapes me.
I have been framing the sheet view within my working model or model space for close to a decade now. One of the primary reason for doing this is it allows everyone to see the defined drawing areas for both the floor plan and remaining white space. I have worked with people who didn't clearly define the working space and it usually leads to unclear scattered information or poorly configured viewports. By the way, I then use the frames to create views and utilize Sheet Set Manager and Project Navigator to setup the sheet (I prefer to follow the AIA Model file/Sheet file concept instead of a bunch of tabs within the same drawing).
To the OP ... the code below doesn't currently include an error trap, object filtering on the entsel (expects polyline rectangle), layout manipulation (tilemode will switch to last selected layout tab), or the option to create the viewport as a standalone command. It is provided more as a starting point, you may need to modify portions to get it to function properly. It also currently expects the views and viewports to reside in the same drawing ...
Code:
;; Use polyline rectangle to create a named model view and then recreate viewport on layout tab
;; Switch to associated layout tab before running or modify as needed to handle layout switch
(defun c:rec2view ( / old_osmode poly_list obj_poly poly_vertex x_min x_max y_min y-max lower_pt1 upper_pt2 name vscale insert_pt)
;; select polyline rectangle to create named model view
(setq old_osmode (getvar "osmode"))
(setvar "osmode" 0)
(setq poly_list (entget (car (setq obj_poly (entsel))))) ;requires user to select polyline rectangle
(setq poly_vertex (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) poly_list)))
(if (> (car (car poly_vertex)) (car (cadr poly_vertex)))
(progn (setq x_max (car (car poly_vertex))) (setq x_min (car (cadr poly_vertex))))
(progn (setq x_min (car (car poly_vertex))) (setq x_max (car (cadr poly_vertex))))
)
(if (> (cadr (car poly_vertex)) (cadr (cadddr poly_vertex)))
(progn (setq y_max (cadr (car poly_vertex))) (setq y_min (cadr (cadddr poly_vertex))))
(progn (setq y_min (cadr (car poly_vertex))) (setq y_max (cadr (cadddr poly_vertex))))
)
(setq lower_pt1 (list x_min y_min))
(setq upper_pt2 (list x_max y_max))
(command "chprop" obj_poly "" "la" "G-Anno-Nplt" "") ;change layer name to match normally available layer or remove line
(setq name (getstring T "\nEnter view name <ENTER>: "))
(while (tblsearch "view" name)
(setq name (getstring T "\nView name already exists, please enter new name <ENTER>: "))
)
(command "-view" "s" name "e" "l" name "s" "" "")
(command "-view" "w" name lower_pt1 upper_pt2)
(setq vscale (/ 1 (getvar "cannoscalevalue"))) ;can be switched out for (getvar "dimscale") or forced to be a specific scale
(command "-text" "j" "br" upper_pt2 (* 0.0975 vscale) "" (strcat "View Name: " name " Dimscale: " (rtos (getvar "dimscale") 2 0)) "")
(command "chprop" (entlast) "" "la" "G-Anno-Nplt" "") ;change layer name to match normally available non-plot layer or remove line
;; create viewport and set to named model view
(setvar "tilemode" 0)
(setvar "osmode" old_osmode)
(while (not insert_pt)
(setq insert_pt (getpoint "\nSelect insert point of view: "))
)
(setvar "osmode" 0)
(command "rectangle" insert_pt (strcat "@" (rtos (/ (- (car upper_pt2) (car lower_pt1)) vscale)) "," (rtos (/ (- (cadr upper_pt2) (cadr lower_pt1)) vscale))))
(command "chprop" (entlast) "" "la" "G-Vprt" "") ;change layer name to match normally available viewport layer or remove line
(command "mview" "object" (entlast))
(command "mspace")
(command "view" "restore" name)
(command "pspace")
(command "mview" "lock" "on" "all" "")
(setvar "osmode" old_osmode)
)