Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

AutoLISP Help

Anonymous

AutoLISP Help

Anonymous
No aplicable

Hello,

I trying to add something to a lisp command that I have which uses Lee Mac's Viewport Outline LISP to create an outline in model space from a viewport and then zoom to that outline in model and delete the outline. I just want to add a safeguard to prevent the lisp from continuing if I do not select something. How would I achieve this?

 

;;;Model zoom to viewport
(defun c:zb ()
  (c:vat)
  (setq a(entlast))
  (command "layout" "set" "model")
  (command "zoom" "object" a "")
  (command "erase" a "")
  (princ)
  )

"c:vat" is the Lee Mac Viewport Outline LISP.

 

Thank you!

Michael

0 Me gusta
Responder
477 Vistas
2 Respuestas
Respuestas (2)

Kent1Cooper
Consultant
Consultant

So it puts the outline of a selected Viewport's viewed area into Model Space, and you go into the Model Space tab and Zoom to that object, and then erase it?  If the idea is to select a Paper Space Viewport, go into the Model Space tab and Zoom to the area shown in that Viewport, here is a far easier way to do it, that does not involve drawing any temporary object:

(defun C:ZVAM (/ vpdata); = Zoom to Viewport's Area in Model tab
  (setq vpdata (entget (car (entsel "\nSelect Viewport to Zoom to its area in Model Space: "))))
  (setvar 'tilemode 1); into Model Space tab
  (command "_.zoom" "_c" "_none" (cdr (assoc 12 vpdata)) (cdr (assoc 45 vpdata)))
  (princ)
); defun

The 12-code entry in a Viewport's entity data is the center of the view in Model Space units, and the 45-code entry is its height in Model Space.

 

It doesn't verify that you're in paper space when you start, but could be made to, and to verify that you actually selected a Viewport, but first see whether it does what you want when you control for those things.

 

[Curiously, calling for the Center option in Zoom needs to be by that initial letter only -- spelling out  "_cen" or "_center" is taken as an Osnap call, and it doesn't like "_none" in response to that.]

Kent Cooper, AIA
0 Me gusta

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... It doesn't verify that you're in paper space when you start, but could be made to, and to verify that you actually selected a Viewport ....


Like this:

(defun C:ZVAM (/ vp vpdata); = Zoom to Viewport Area in Model Space
  (if
    (and 
      (= (getvar 'tilemode) 0); in Paper Space
      (setq vp (car (entsel "\nSelect Viewport to Zoom to its area in Model Space: ")))
      (setq vpdata (entget vp))
      (member '(0 . "VIEWPORT") vpdata)
    ); and
    (progn ; then
      (setvar 'tilemode 1); into Model Space tab
      (command "_.zoom" "_c" "_none" (cdr (assoc 12 vpdata)) (cdr (assoc 45 vpdata)))
    ); progn
    (prompt "\nYou are not in Paper Space, or did not select a Viewport."); else
  ); if
  (princ)
); defun
Kent Cooper, AIA
0 Me gusta