Author Topic: troubleshooting with viewports !!  (Read 1811 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
troubleshooting with viewports !!
« on: August 27, 2015, 12:29:44 PM »
Hi i have troubleshooting with my view ports. I have a drawing in the model space. I make my viewports and i forget to lock them. I use a lisp to draw in my model space a viewport outline. The problem  is that i move me drawng and now i can't center it again in the same viewport outline. I am searching for a lisp to select in the modelspace  the viewport outline and then select the layout and center the viewport outline to the viewport.

Thanks

BuckoAk

  • Newt
  • Posts: 69
Re: troubleshooting with viewports !!
« Reply #1 on: August 27, 2015, 12:49:35 PM »
If the size of the outline in model-space and the view-port in paper-space has not changed, activate your view-port zoom out so you can see all of the corners of the outline.  Then use the zoom command picking the opposite corners of the outline, this will snap your view back to it's original location.

pedroantonio

  • Guest
Re: troubleshooting with viewports !!
« Reply #2 on: August 27, 2015, 12:56:58 PM »
You mean to zoom -> window ?

Lee Mac

  • Seagull
  • Posts: 12752
  • London, England
Re: troubleshooting with viewports !!
« Reply #3 on: August 27, 2015, 01:03:18 PM »
The following will allow you to make a selection of any objects to center (at optimum zoom) within the active viewport:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:cvp ( / sel )
  2.     (cond
  3.         (   (= 1 (getvar 'tilemode))
  4.             (princ "\nThis command is only available within a Paperspace Layout.")
  5.         )
  6.         (   (= 1 (getvar 'cvport))
  7.             (princ "\nPlease activate a viewport.")
  8.         )
  9.         (   (setq sel (ssget))
  10.             (apply 'vla-zoomwindow
  11.                 (cons (vlax-get-acad-object)
  12.                     (mapcar 'vlax-3D-point (LM:ssboundingbox sel))
  13.                 )
  14.             )
  15.         )
  16.     )
  17.     (princ)
  18. )
  19.  
  20. ;; Selection Set Bounding Box  -  Lee Mac
  21. ;; Returns a list of the lower-left and upper-right WCS coordinates of a
  22. ;; rectangular frame bounding all objects in a supplied selection set.
  23. ;; s - [sel] Selection set for which to return bounding box
  24.  
  25. (defun LM:ssboundingbox ( s / a b i m n o )
  26.     (repeat (setq i (sslength s))
  27.         (if
  28.             (and
  29.                 (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
  30.                 (vlax-method-applicable-p o 'getboundingbox)
  31.                 (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list o 'a 'b))))
  32.             )
  33.             (setq m (cons (vlax-safearray->list a) m)
  34.                   n (cons (vlax-safearray->list b) n)
  35.             )
  36.         )
  37.     )
  38.     (if (and m n)
  39.         (mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list m n))
  40.     )
  41. )
  42.  

pedroantonio

  • Guest
Re: troubleshooting with viewports !!
« Reply #4 on: August 27, 2015, 01:07:45 PM »
Thank you Lee Mac nice job !!!