Jump to content

Recommended Posts

Posted

Hi everyone, I have already looked at the variables and was wondering if the last scale factor used, by picking points, is stored somewhere. I have to pass it to the zoom command afterwards.

I need to create a lisp command that allows me to scale a viewports and zoom internally at the same time by the same scale factor, so as to have a sort of scaling of the window and the drawing contained in it.

Can anyone kindly help me? Thank you.

Enrico

Posted

I think...

 

(setq currentzoom (list (getvar 'viewctr) (getvar 'viewsize)))  ;; List (centre of screen, View Size)

 

And to return to that zoom:

 

(vla-ZoomCenter (vlax-get-acad-object) (vlax-3d-point (car currentzoom)) (cadr currentzoom))

 

  • Agree 1
Posted

we would save drawings up and rename to new revision number so when going back to "check" things you would have to open the older version drawing. This would make sure you where looking at the same xy location.

 

;;----------------------------------------------------------------------------;;
;; Zoom Area Across Multiple Drawings
(defun C:ZAD (/ a)  ;Zoom Across Drawings
  (initget "Yes No")
  (setq a
    (cond
      ((getkword "\nRedefine Zoom Area? [Yes/No]: ")) ( "No")
    )
  )
  (if (= "Yes" a)
    (progn
      (vl-cmdf "_.Zoom" "W" Pause Pause)
      (setq vc (getvar 'viewctr))
      (setq SZ (getvar 'viewsize))
      (vl-propagate 'vc)
      (vl-propagate 'sz)
    )
    (if (or (= vc nil) (= sz nil))
      (prompt "\nPlease Define Zoom Area")
      (vl-cmdf "_.Zoom" "C" VC SZ)
    )
  )
  (princ)
)

 

Posted

My $0.05 we always lock a viewport after setting a zoomed view. if you use ZOOM C point scale, it will set the centroid of the viewport to a Model space point, scale is not important at this stage, you can then reset the zoom scale say zoom 10xp, but the centroid will remain, then we lock the viewport. I think that is what your looking at doing. 

 

If your metric working out the zoom scaleXP is easy as scale is a function of either 1.0 or 1000. eg 1:250 = 1000/250 = 4 = 4XP if working in metres.

Posted (edited)

Thank you all,
but I think there was a misunderstanding with my topic.
With the example of the attached image I hope to be more understandable.
I have a viewport (in red on left) with the view of an object inside (with a annoscale that is not necessarily defined), with a kind of scale command I need that by scaling the viewport the view internally also scales by the same scale factor (example on the right).

Thanks again

Immagine 2025-02-21 135836.png

Edited by EnricoTV
Posted

So sounds like scale doesn't really matter you just want it to look the same ratio. Have a command that takes the outline of the view port and puts it into model space. So once you are done scaling the view port to the new size you would then zoom window and pick that outline.

 

Posted (edited)

Funny you should say that....

 

ZVPRect (Zoom ViewPort Rectangle) - click in viewport, ZVPRECT, select rectangle, exit viewport)

 

;;https://forums.autodesk.com/t5/autocad-forum/having-trouble-with-the-lisp-that-zooms-a-rectangle-that-fits-in/td-p/9378532
(defun c:zvprect ( / a b e o)
 (if (setq e (car (entsel "\nSelect Rectangle : ")))
   (progn
     (setq o (vlax-ename->vla-object e))
     (vlax-invoke-method o 'GetBoundingBox 'a 'b)
     (setq a (vlax-safearray->list a)
           b (vlax-safearray->list b)
     )
     (vl-cmdf "_.zoom" a b)
     )
   )
 (princ)
)

 

 

Draw a rectangle round the parts to show their viewport area to make this work best, perhaps on an non-plotting layer in case the rectangle isn't the same proportions as the viewport

Edited by Steven P
  • Agree 1
Posted (edited)

Like I said this creates a viewport outline in model space.  for each view port on the tab its run on.

 

so to do what you are asking

 

  • run VP2M
  • resize the viewport
  • then use @Steven P's lisp or zoom window command.

 

VP2M.lsp

Edited by mhupp
  • Like 1
Posted

Thank you all,

I solved the dilemma with Named Views. This will set the viewport to the correct view no matter the size/scale of the VP.

 

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