Author Topic: Zoom Extents, All Open Drawings  (Read 4834 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Zoom Extents, All Open Drawings
« on: October 17, 2003, 12:11:20 PM »
Will someone please try this out and let me know if it works for them. I can't get it to work. I've followed The VisuaLisp's Developer's Bible and besides taking out the counting feature in Dave's rendition, I can't seem to figure out why I can't get it to work. Speaking of Dave, does anybody think he'd be interested in joining this board?
Code: [Select]

(defun c:zea ()
     (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object)))
     ;(deselect) not necessary
     (setq $acad   (vlax-get-acad-object)
  alldocs (vla-get-documents $acad)
  this   (vla-get-activedocument $acad)
     )
     (defun ZoomExtents ()
 (vla-put-ActiveDocument each);|<-Doesn't this pick up the object when it's run under vlax-for?|;
 (vla-ZoomExtents $acad)
 (vla-put-ActiveDocument this)
 (vlax-release-object $acad)
 (vlax-release-object alldocs)
     )
     (vlax-for each alldocs
 (if (= (vla-get-ActiveSpace each) 0) ; If in paperspace
      (cond
   ((and (= (vla-get-MSpace each) :vlax-True)
 ; in mspace viewport
 (= (vla-get-DisplayLocked
 (vla-Get-ActivePViewport each)
    )
    :vlax-True
 ) ; Mspace viewport is locked
    )
    (vla-put-MSpace each :vlax-False)
    (ZoomExtents)
    (vla-put-MSpace each :vlax-True)
   )
   ((and (= (vla-get-MSpace each) :vlax-True)
 ; in mspace viewport
 (= (vla-get-DisplayLocked
 (vla-Get-ActivePViewport each)
    )
    :vlax-False
 ) ; Mspace viewport is not locked
    )
    (ZoomExtents)
   )
   ((= (vla-get-MSpace each) :vlax-False)
    (ZoomExtents)
   )
      )
      (ZoomExtents)
 )
     )
     (vla-EndUndoMark (vla-get-activedocument (vlax-get-acad-object)))
     (princ)
)

JohnK

  • Administrator
  • Seagull
  • Posts: 10140
Zoom Extents, All Open Drawings
« Reply #1 on: October 17, 2003, 12:18:55 PM »
Here are my initial thoughts. (I dont have a bunch of time untill lunch, but see if this helps)

This is the first part of your program.
Code: [Select]
(defun c:zea ()
  (vla-StartUndoMark (get-active-document)) ;;<- needed function
  (deselect) ;;<- needed function
  (setq $acad (vlax-get-acad-object)
        alldocs (vla-get-documents $acad)
        this      (vla-get-activedocument $acad)
        )
  (defun ZoomExtents ()
    (vla-put-ActiveDocument each) ;;<- object needed
    (vla-ZoomExtents $acad)
    (vla-put-ActiveDocument this)
    (vlax-release-object $acad)
    (vlax-release-object alldocs)
   )
...
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

daron

  • Guest
Zoom Extents, All Open Drawings
« Reply #2 on: October 17, 2003, 12:53:43 PM »
I've modified the original code. It still isn't working.

JohnK

  • Administrator
  • Seagull
  • Posts: 10140
Zoom Extents, All Open Drawings
« Reply #3 on: October 17, 2003, 01:08:14 PM »
What is the purpose of this code? At a quick glance, it looks like hes trying to zoom extents each drawing in the collection.  

*Quick thoughts*
-Whats the modelspace for? Is he trying to zoom extents modelspace and not paperspace?
-What is the reference to the viewport for?

Alright, ill look into this code for ya. give me a sec.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

daron

  • Guest
Zoom Extents, All Open Drawings
« Reply #4 on: October 17, 2003, 01:25:09 PM »
You ever have a locked viewport while in paperspace and you use (vla-zoomextents (vlax-get-acad-object))? Does it care if the vport is locked? No. That's what all the extra code is for. And yes, I am trying to zoom extents all open drawings regardless of space.