Artek Posted October 1, 2018 Posted October 1, 2018 Hi, Any chance someone can help me with a lisp code on zooming in to a specific attribute tag in a block? There's only one instance of the block in every tab and that block contains multiple attributes. I saw some codes about zooming to attribute values but not to a tag. Thanks. Quote
Tharwat Posted October 1, 2018 Posted October 1, 2018 (edited) Hi, Something like this? (defun c:Test (/ tag int sel ent vla zom lft rgt) (setq tag "YourTag") ;; tag name. (if (and (setq tag (strcase tag) int -1 sel (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 410 (getvar 'CTAB))))) (progn (while (and (setq ent (ssname sel (setq int (1+ int)))) (setq vla (vlax-ename->vla-object ent)) (not (vl-some '(lambda (x) (and (= (strcase (vla-get-tagstring x)) tag) (setq zom vla) ) ) (vlax-invoke vla 'getattributes) ) ) ) ) (if zom (progn (vla-getboundingbox zom 'lft 'rgt) t))) ) (vla-ZoomWindow (vlax-get-acad-object) lft rgt) (alert "No tag string found!") ) (princ) ) (vl-load-com) Edited October 1, 2018 by Tharwat Quote
Artek Posted October 1, 2018 Author Posted October 1, 2018 Many thanks Tharwat for responding to my query. I just tested it and it's zooming to the extent of the block where the tag resides. Is it possible to make it zoom in only to the tag string? Quote
BIGAL Posted October 2, 2018 Posted October 2, 2018 You should be able to get at the attributes properties this is a test code. (setq atts (vlax-invoke (vlax-ename->vla-object (car (entsel "\nPick block attribute")))'getattributes)) (foreach att atts (princ (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint att)))) ; multi points should appear ) Tharwat has written good code and it would be best for him to add your specific request as a slightly different version. For me finding the block should be good enough. Quote
rlx Posted October 2, 2018 Posted October 2, 2018 (edited) Beautifull code indeed! about the request , all OP has to do is change (setq zom vla) to (setq zom x) ... somewhere in the middle of the code p.s. assuming TAG has a boundingbox (isn't empty) else you would need a zoom center on its insertion point or zoom to the block anyway (untested) : (defun c:Test2 (/ tag int sel ent vla zom lft rgt) (setq tag "YourTagname") ;; tag name or replace with getstring (setq tag (getstring "\nEnter tagname to search for : ")) (if (and (setq tag (strcase tag) int -1 sel (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 410 (getvar 'CTAB))))) (progn (while (and (setq ent (ssname sel (setq int (1+ int)))) (setq vla (vlax-ename->vla-object ent)) (not (vl-some '(lambda (x) (and (= (strcase (vla-get-tagstring x)) tag)(setq zom x))) (vlax-invoke vla 'getattributes))))) (and zom ;if tagname was found, and it has boundingbox , use it , else use block boundingbox (or (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list zom 'lft 'rgt)))) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list vla 'lft 'rgt)))))))) (vla-ZoomWindow (vlax-get-acad-object) lft rgt) (alert (strcat "Tagstring " tag " not found"))) (princ) ) Edited October 2, 2018 by rlx Quote
BIGAL Posted October 3, 2018 Posted October 3, 2018 (edited) Zoom C Scale on the tag insertion position but need to know the scale factor maybe still use bounding box with a fuzz factor say 1/4 box size for scale value Edited October 3, 2018 by BIGAL Quote
Artek Posted October 3, 2018 Author Posted October 3, 2018 Thanks very much Thartwat, Bigal & rlx for all your help. Greatly appreciated. Quote
Recommended Posts
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.