Author Topic: Improve performance on multiple passages between model and layout  (Read 1653 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 338
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  :cry:


Code: [Select]
(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")
  ;------------
)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Improve performance on multiple passages between model and layout
« Reply #1 on: October 07, 2015, 08:42:24 AM »
You can create a viewport programmatically in which case there is no reason to switch between MS and PS.
Here is an example to get you started:
http://www.theswamp.org/index.php?topic=47145.msg521777#msg521777

The example does switch between MS and PS, but that can be removed.
Note:
To get the PS block belonging to a specific layout you can use:
Code: [Select]
(vla-get-block (vla-item (vla-get-layouts doc) nameOfLayout))Instead of:
Code: [Select]
(vla-get-paperspace doc)

Lupo76

  • Bull Frog
  • Posts: 338
Re: Improve performance on multiple passages between model and layout
« Reply #2 on: October 07, 2015, 11:15:02 AM »
You can create a viewport programmatically in which case there is no reason to switch between MS and PS.
Here is an example to get you started:
http://www.theswamp.org/index.php?topic=47145.msg521777#msg521777

The example does switch between MS and PS, but that can be removed.

Thank you for your answer!

How can I remove the switch between MS and PS?
I find in the code:
Code: [Select]
(command "_.mview" ......)

So I think before moving into the correct layout.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Improve performance on multiple passages between model and layout
« Reply #3 on: October 07, 2015, 11:48:00 AM »
The Lisp code attached to the post I have linked to does not contain any command calls.
http://www.theswamp.org/index.php?action=dlattach;topic=47145.0;attach=27500