Jump to content

[Help] Zoom to list of handle ID


littlepeterpan821

Recommended Posts

I founded that this lisp is just simple but great, anyone can help me edit a little bit more pls!? I have a list of handle ID like

A;B;C;D....

I wanna use this lisp for single HandleID either for multiple HandleID too!! ^^

Thank You in Advance!!!!

(defun c:zh ( / YourHandle ll ur )
 (vl-load-com)
 (setq YourHandle (getstring "\nEnter Handle: "))
 (if (handent YourHandle)
   (progn
     (vla-getboundingbox (vlax-ename->vla-object (handent YourHandle)) 'll 'ur)
     (vla-zoomwindow (vlax-get-acad-object) ll ur)
     (sssetfirst nil (ssadd (handent YourHandle)))
   )
   (princ "\nHandle not in drawing")
 )
 (princ)
)

Link to comment
Share on other sites

:roll: Loop through each member of your list and pass it as an argument to your function.

 

 

(defun c:test (/ choice handle-list)
 (vl-load-com)
 (setq handle-list (list "111" "112" "A" "B" "C" "D")) [color=red];yust an example[/color]

 (foreach item handle-list [color=red]; start the loop[/color]
   (initget "Yes No") [color=red]; pause or exit zooming #1[/color]
   (if item
     (progn
       (c:zh item) [color=red]; call your function[/color]
       (setq choice (getkword "\nZoom to next object? (Yes/No)"))[color=red]; pause or exit zooming #2[/color]
       (if (= choice "Yes") [color=red]; continue or exit the loop[/color]
         (princ "\nzooming to next object")
         (exit)
         )
       )
     )
   )
 (princ) [color=red]; force clean exit[/color]
 )

(defun c:zh ([color=blue]YourHandle[/color][color=red] /[/color] ll ur) ; note that "YourHandle" is now global
 (vl-load-com)
                                      [color=red] ;[/color](setq YourHandle (getstring "\nEnter Handle: ")) [color=red]; comment or delete this line[/color]
 (if (handent YourHandle)
   (progn
     (vla-getboundingbox
       (vlax-ename->vla-object (handent YourHandle))
       'll
       'ur
       )
     (vla-zoomwindow (vlax-get-acad-object) ll ur)
     (sssetfirst nil (ssadd (handent YourHandle)))
     )
   (princ "\nHandle not in drawing")
   )
 (princ)
 )

(c:test)[color=red];autostart[/color]

regards

Wolfgang

Link to comment
Share on other sites

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