Hello to all,
I found the following code on the web and I adapted to my needs.
This code allows you to create a viewport inside a layout starting from 2 points in model space.
Unfortunately this code is placed inside a while loop and is repeated at least 70-80 times, and so it could take up to 5-10 minutes or more for the entire processing.
This happens because the continuous transition between model space and paper space is very slow.

There is a variable that allows you to run lisp without regenerating the screen at each step?
I thought REGENMODE = 0 but always appears a message screen that asks for confirmation, which stops the operation
I also thought of LAYOUTREGENCTL, but the improvements are not enough

(defun CreaLayout (p1 p2 n / doc temp mp scl SC res a b vpp vpdoc vp)
; ;------------
(setq NomeLayout (strcat "F. " (itoa n)))
(command "_.-layout" "_n" NomeLayout)
(command "_.-layout" "_s" NomeLayout)
(command "_.erase" "_all" "")
(setq Doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(if
(< (car (trans p2 1 0)) (car (trans p1 1 0)))
(setq tmp p1
p1 p2
p2 tmp
)
T
)
(setq mp (list (/ (+ (car p1) (car p2)) 2)
(/ (+ (cadr p1) (cadr p2)) 2)
0.0
)
)
(setq sc 1)
(command "_.-layout" "_s" NomeLayout)
(setq VPDoc (vla-get-PaperSpace doc))
(setq VPp (vlax-3D-point (list 0.0 0.0 0.0)))
(setq VP (vla-AddPViewport
VPDoc
VPp
(/ (- (car p2) (car p1)) sc)
(/ (- (cadr p2) (cadr p1)) sc)
)
)
(vla-display VP :vlax-true)
(vla-put-mspace doc :vlax-true)
(vla-put-activepviewport Doc VP)
(vla-zoomcenter
(vlax-get-acad-object)
(vlax-3d-point mp)
1.0
)
(vl-cmdf "_.zoom" (strcat (RTOS (/ 1.0 SC)) "xp"))
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
acActiveViewport
)
(vla-put-mspace doc :vlax-FALSE)
(VLA-PUT-DisplayLocked VP :vlax-true)
; ;------------
;------------
(command "_.-plot" "_y" NomeLayout "DWG To PDF.pc3" "A3 IN(420.00 x 297.00 mm)" "_m" "_l" "_n" "_w" "-210.00,-148.44" " 210.00,148.44" "1" "0,0" "_y" "." "_y" "_n" "_n" "_n" "_n" "_y" "_n")
;------------
)