Jump to content

How to zoom to block using block name, one by one if there are more in dwg


Recommended Posts

Posted

Need to pinpoint blocks in dwg model space somehow.

Blocks I need to find are alone in model space, but some are included in other blocks as well. I need to go trough all blocks and their nested items to find all instances of a block with same name.

 

It would be nice to zoom them one by one.

Posted (edited)

I'm an idiot....

 

BEDIT, draw big mark in the problem block save edit and look at the drawing...

 

if there is no block in a drawing use superpurge or something to remove it...

 

Addendum...

Be careful with dynamic blocks that have visibility feature used, when adding mark make it visible in all states.

Edited by ibach
Posted

You can use ssget a unique block name and then zoom to each one is pretty simple code, I would pick 1 block so get name. If you want an example code post again.

Posted

sure i'd like the example.

I'm not good at programming.

Posted

Try this ...

 

(defun c:Test (/ *error* name ss i obj lft rgt)
 (vl-load-com)
;;; Tharwat 13. jan. 2013 ;;;
 (defun *error* (x) (princ "\n *Cancel*"))
 (if (and (/= (setq name (getstring t "\n Specify Block name :")) "")
          (/= name nil)
          (setq ss (ssget "_x" (list '(0 . "INSERT") (cons 410 (getvar 'ctab)) (cons 2 name))))
     )
   (progn (repeat (setq i (sslength ss))
            (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
            (vla-getboundingbox obj 'l 'r)
            (setq mid (mapcar (function (lambda (q p) (/ (+ q p) 2.)))
                              (setq lft (vlax-safearray->list l))
                              (setq rgt (vlax-safearray->list r))
                      )
            )
            (vla-ZoomCenter
              (vlax-get-acad-object)
              (vlax-3d-point mid)
              (distance lft (list (car rgt) (cadr lft)))
            )
            (if (eq "" (getstring "\n Press enter to continue or space bar:"))
              (princ)
            )
          )
          (alert "*** DONE ***")
   )
   (princ)
 )
 (princ)
)

  • Like 1

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