Author Topic: What's wrong with the "cvport" system variable?  (Read 2196 times)

0 Members and 1 Guest are viewing this topic.

cjw

  • Guest
What's wrong with the "cvport" system variable?
« on: January 07, 2009, 04:23:23 AM »
Sometime it work,sometime it doesn't.
can't setvariable "cvport"

You can test the code.

I don't know how to fix it. please help. :oops:
Thanks.

Code: [Select]
(vl-load-com)
(defun C:TT (/ ACADDOC ACADOBJ CTAB ELIST LAYOUTS PT1 PT3 SCALE V10 V69
     VPE VPO)
  (setvar "cmdecho" 0)
  (setq ACADOBJ (vlax-get-acad-object))
  (setq ACADDOC (vla-get-activedocument ACADOBJ))
  (setq CTAB (getvar "ctab"))
  (setq LAYOUTS (layoutlist))
  (if (= CTAB "Model")
    (setq CTAB (car LAYOUTS))
    (setvar "ctab" "Model")
  )
  (if
    (and
      (setq PT1 (getpoint "\nGet the first point: "))
      (setq PT3 (getcorner PT1 "\nGet the corner: "))
      (if (setq SCALE (getreal "\nInput the viewport scale 1:<100> "))
t
(setq SCALE 100.)
      )
      (> SCALE 0)
    )
     (progn
       (setvar "ctab" CTAB)
       (command "._pspace")
       (command "._mview" "none" PT1 "none" PT3) ;_MAKE VIEWPORT

       (setq VPE (entlast))
       (setq VPO (vlax-ename->vla-object VPE))
       (setq ELIST (entget VPE))
       (setq V10 (cdr (assoc 10 ELIST))) ;_VIEWPORT CENTER
       (setq V69 (cdr (assoc 69 ELIST))) ;_VIEWPORT ID

       (command "._mspace")
       (setvar "cvport" V69)
       (command "._zoom" "w" "none" PT1 "none" PT3)
       (command "._pspace")

       (setq SCALE (/ 1 SCALE))
       (vla-put-standardscale VPO acvpcustomscale)
       (vla-put-customscale VPO SCALE)

       (command "._scale" VPE "" "none" V10 SCALE)
       (command "._move"
VPE
""
"none"
(cadr (assoc V69 (vports)))
'(0 0 0)
       )
       (command "._move" VPE "" "none" '(0 0 0) PAUSE)
     )
  )
  (setvar "cmdecho" 1)
  (princ)
)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: What's wrong with the "cvport" system variable?
« Reply #1 on: January 07, 2009, 10:32:29 AM »
It bombs when you are trying to set the variable and the newly created viewport is not visible. Give the code below a try...it performs a zoom extents then zooms back to '(0 0 0) so the viewport can be moved.

Code: [Select]
(vl-load-com)
(defun c:tt (/ acaddoc acadobj ctab elist layouts pt1 pt3 scale v10 v69 vpe vpo)
  (setvar "cmdecho" 0)
  (setq acadobj (vlax-get-acad-object))
  (setq acaddoc (vla-get-activedocument acadobj))
  (setq ctab (getvar "ctab"))
  (setq layouts (layoutlist))
  (if (= ctab "Model")
    (setq ctab (car layouts))
    (setvar "ctab" "Model")
  )
  (if (and (setq pt1 (getpoint "\nGet the first point: "))
           (setq pt3 (getcorner pt1 "\nGet the corner: "))
           (if (setq scale (getreal "\nInput the viewport scale 1:<100> "))
             t
             (setq scale 100.)
           )
           (> scale 0)
      )
    (progn (setvar "ctab" ctab)
           (command "._pspace")
           (command "._mview" "none" pt1 "none" pt3) ;_MAKE VIEWPORT
           (setq vpe (entlast))
           (setq vpo (vlax-ename->vla-object vpe))
           (setq elist (entget vpe))
           (setq v10 (cdr (assoc 10 elist))) ;_VIEWPORT CENTER
           (setq v69 (cdr (assoc 69 elist))) ;_VIEWPORT ID
           (command "._zoom" "_e")
           (command "._mspace")
           (setvar "cvport" v69)
           (command "._zoom" "w" "none" pt1 "none" pt3)
           (command "._pspace")
           (setq scale (/ 1 scale))
           (vla-put-standardscale vpo acvpcustomscale)
           (vla-put-customscale vpo scale)
           (command "._scale" vpe "" "none" v10 scale)
           (command "._move"
                    vpe
                    ""
                    "none"
                    (cadr (assoc v69 (vports)))
                    '(0 0 0)
           )
           (command "._zoom" "_c" '(0 0 0)(distance pt1 pt3))
           (command "._move" vpe "" "none" '(0 0 0) pause)
    )
  )
  (setvar "cmdecho" 1)
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cjw

  • Guest
Re: What's wrong with the "cvport" system variable?
« Reply #2 on: January 07, 2009, 07:39:27 PM »
I pay many time to test the code but didn't fix it.

ron,Thank you very very much...

Your code is OK

ronjonp

  • Needs a day job
  • Posts: 7526
Re: What's wrong with the "cvport" system variable?
« Reply #3 on: January 07, 2009, 11:21:57 PM »
I pay many time to test the code but didn't fix it.

ron,Thank you very very much...

Your code is OK


Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC