Jump to content

Recommended Posts

Posted

Good afternoon,

I'm trying to create simple toolbar icons to rotate my view while building elevations and roof layouts. The existing buttons work fine, but zoom extents when I change UCS rotations. For some reason, my code is capturing the viewctr wrong. I just want to carry my zoom factor and view center to the next rotated UCS plan view. Any help would be much appreciated.

 

Thanks for all your help,

Mike in Dallas

 

(defun C:ELS (/ vctr vsze)
       (setq vctr (getvar "viewctr"))
       (setq vsze (getvar "viewsize"))
   (command "ucs" "W")
   (command "plan" "")
   (command "zoom" "_c" vctr vsze)
)    
;
;
;
(defun C:ELN (/ vctr vsze)
       (setq vctr (getvar "viewctr"))
       (setq vsze (getvar "viewsize"))
   (command "ucs" "z" "180")
   (command "plan" "")
   (command "zoom" "_c" vctr vsze)
)
;
;
(defun C:ELE (/ vctr vsze)
       (setq vctr (getvar "viewctr"))
       (setq vsze (getvar "viewsize"))
   (command "ucs" "z" "90")
   (command "plan" "")
   (command "zoom" "_c" vctr vsze)
)
;
;
(defun C:ELW (/ vctr vsze)
       (setq vctr (getvar "viewctr"))
       (setq vsze (getvar "viewsize"))
   (command "ucs" "z" "270")
   (command "plan" "")
   (command "zoom" "_c" vctr vsze)
)

Posted

You could always just TWIST, and UNTWIST your view (no more zoom):

 

(vl-load-com)

;;;--------------------------------------------------------------------;
;;; Twist dview function:
(defun c:TW () (c:TWIST))
(defun c:TWIST (/ *error* RTD oldCmdecho oldOsmode pt1 pt2 acDoc)
 (prompt "\rTWIST")

 (defun *error* (msg)
   (and oldCmdecho (setvar 'cmdecho oldCmdecho))
   (and oldOsmode (setvar 'osmode oldOsmode))
   (if acDoc
     (vla-endundomark acDoc)
   )
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
   )
   (princ)
 )

 (defun RTD (ang) (/ (* ang 180.0) pi))

 (if (and (setq oldCmdecho (getvar 'cmdecho))
          (setvar 'cmdecho 0)
          (setq oldOsmode (getvar 'osmode))
          (setvar 'osmode 512)
          (setq pt1 (getpoint "\nSpecify start point (left): "))
          (not (initget 32))
          (setq pt2 (getpoint "\nSpecify end point (right): " pt1))
     )
   (progn
     (vla-startundomark
       (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
     )
     (command "._dview" "l" "" "PO" "@0,0,0" "@0,0,1" "")
     (command "._dview"
              "l"
              ""
              "tw"
              (- 360 (RTD (setq ang (angle pt1 pt2))))
              ""
     )
     (setvar 'snapang ang)
   )
 )
 (*error* nil)
)
;;;--------------------------------------------------------------------;
;;; Untwist dview function:
(defun c:UTW () (c:UNTWIST))
(defun c:UNTWIST (/ *error* oldCmdecho)
 (prompt "\rUNTWIST")

 (defun *error* (msg)
   (and oldCmdecho (setvar 'cmdecho oldCmdecho))
   (and oldNomutt (setvar 'nomutt oldNomutt))
   (if acDoc (vla-endundomark acDoc))
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
   )
   (princ)
 )

 (setq oldCmdecho (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (command "._dview" "l" "" "tw" 0 "")
 (setvar 'snapang 0)
 (command "._UCS" "W")
 (*error* nil)
)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...