Zoom to selected entities

Discussion in 'AutoCAD' started by Bill Voigt, Dec 26, 2003.

  1. Bill Voigt

    Bill Voigt Guest

    I often will do a quick select in large dwgs. Before I perform a global
    operation on the selected objects, I would like to zoom to the object(s) to
    see what has been selected. Does anyone know where of a lisp/vba routine
    to zoom to selected objects?

    Conceptually, the routine would zoom to the extent of all selected items.
    In my fantasy version the routine would display a dialog listing the
    original selected items in a listbox, displaying text value, entity type,
    handle, depending on the object selected. The user then refines his selected
    items by eliminated unwanted entities from the list. Obviously, it would
    work best for small selection sets.

    Many thanks,
    --Bill

    William G Voigt (415) 485-3366 voice
    GIS Analyst (415) 485-3334 fax
    Dept Public Works 111 Morphew St
    City of San Rafael San Rafael, CA 94901
     
    Bill Voigt, Dec 26, 2003
    #1
  2. Bill Voigt

    Jeff Mishler Guest

    Bill,
    Here's a lisp that I wrote & use for the Zooming portion of your request. I
    don't do DCL, so I wouldn't be able to add to this to get the list and
    subsequent actions on that list. However, it doesn't seem like it would be
    that difficult to implement in VBA.
    Hmmm, just noticed that you work for the City of San Rafael. I didn't think
    there were any public agencies open today...... <:{/

    Jeff

    ;| Routine to create a selection set and zoom to the
    extents of the ss.
    Jeff Mishler Jun 2003
    |;

    (defun zss (/ count ent ll ll-ent ll-ss ss ur
    ur-ent ur-ss llx lly urx ury)
    (if (setq ss (ssget))
    (progn
    (setq count -1)
    (while (< (setq count (1+ count))(sslength ss))
    (setq ent (vlax-ename->vla-object (ssname ss count)))
    (vla-getboundingbox ent 'll 'ur)
    (setq ll-ent (vlax-safearray->list ll)
    ur-ent (vlax-safearray->list ur))
    (if (not ll-ss)
    (setq ll-ss ll-ent
    ur-ss ur-ent)
    (progn
    (if (< (car ll-ent)(car ll-ss))
    (if (< (cadr ll-ent)(cadr ll-ss))
    (setq ll-ss ll-ent)
    (setq ll-ss (list (car ll-ent)
    (cadr ll-ss))
    )
    )
    (if (< (cadr ll-ent)(cadr ll-ss))
    (setq ll-ss (list (car ll-ss)
    (cadr ll-ent))
    )
    )
    )
    (if (> (car ur-ent)(car ur-ss))
    (if (> (cadr ur-ent)(cadr ur-ss))
    (setq ur-ss ur-ent)
    (setq ur-ss (list (car ur-ent)
    (cadr ur-ss))
    )
    )
    (if (> (cadr ur-ent)(cadr ur-ss))
    (setq ur-ss (list (car ur-ss)
    (cadr ur-ent))
    )
    );if
    );if
    );progn
    );if
    );while
    (setq ll (vlax-3d-point ll-ss)
    ur (vlax-3d-point ur-ss)
    llx (car ll-ss)
    lly (cadr ll-ss)
    urx (car ur-ss)
    ury (cadr ur-ss)
    );setq
    (vla-zoomwindow (vlax-get-acad-object) ll ur)
    (grvecs (list -1
    (list llx lly)(list llx ury)
    (list llx ury)(list urx ury)
    (list urx ury)(list urx lly)
    (list urx lly)(list llx lly)
    )
    )
    );progn
    );if
    (princ)
    );defun
     
    Jeff Mishler, Dec 26, 2003
    #2
  3. Bill Voigt

    Jeff Mishler Guest

    My apologies to this group for my cross-post. I didn't realize that the
    original poster had cross-posted when I replied to him.

    Jeff
     
    Jeff Mishler, Dec 26, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.