Jump to content

Recommended Posts

Posted

Hello all,

 

The routine below is marvelously handy as is, but I was hoping to get some assistance with changing it a little bit. Right now, once I'm in an active viewport I'm prompted to select an object which would ideally be a non plot rectangle around my elevation or section i wish to zoom to. It then sets the Annotation & Standard scales (based on what exactly I'm not quite sure :unsure:)

 

What I would like to do is edit this to have the option of either selecting an object, and selecting the two corners of a zoom window. Any help is appreciated.

 

I've only begun the plunge into seriously studying AutoLISP programming in the last few months, though i've been using it everyday for a few years—still very much a begginer.

 

;;;Viewport zooming & setting nearest scale routine
;;;by: Ranjit.Singh
(vl-load-com)

(defun c:v1  (/ cvp dat3 ent obj Lowerc Upcor etdata etdata2 sc ss1 zf)
(and (zerop (getvar 'tilemode))
     (> (setq cvp (getvar 'cvport)) 1)
     (setq ent (car (entsel "\nSelect object to zoom to: ")))
     (vl-cmdf "._zoom" "_o" ent "")
     (setq ss1 (ssget "_x" (list '(0 . "viewport") (cons 69 cvp) (cons 410 (getvar 'ctab)))))
     (setq zf   (/ (cdr (assoc 41 (setq etdata (entget (setq ent (ssname ss1 0)))))) (cdr (assoc 45 etdata)))
           dat3 (mapcar '(lambda (x)
                          (cons (cdr (assoc 300 (setq etdata2 (entget (cdr x)))))
                                (apply '/ (reverse (cdr (reverse (mapcar 'cdr (member (assoc 140 etdata2) etdata2))))))))
                        (vl-remove-if-not '(lambda (x) (= 350 (car x))) (dictsearch (namedobjdict) "ACAD_SCALELIST"))))
     (setpropertyvalue ent
                       "ViewHeight"
                       (/ (cdr (assoc 41 etdata))
                          (cdr (assoc (setq sc (caar (vl-sort (mapcar '(lambda (x) (cons (car x) (abs (- zf (cdr x))))) dat3)
                                                              '(lambda (x y) (< (cdr x) (cdr y))))))
                                      dat3)))))
(command "_.cannoscale" sc)
 (command "_.pspace" )		;my only additions to Ranjit's code
 (command "zoom" "extents")	;my only additions to Ranjit's code
 
(princ))

Posted

edits:

"...either selecting an object, *or selecting the two corners..."

"...a few years—still very much a *beginner...."

Posted

I don't think this makes any difference functionally, but just to head off any possible confusion. I just realized there are two additional arguments in the in the list that weren't in the original. They are "Lowerc" and "Upcor". I added these when I was first messing with it and forgot to take them out.

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...