stlo Posted May 25, 2023 Share Posted May 25, 2023 Hi everyone! I'm wondering if it's possible to retrieve one value of a block depending on what another value of that same block is and show that value as a text over that same block? I would be kind of an isolated value of the BURST command I guess but keeping the Block as a Block. I'm joining a dwg with details in it and a screen capture! I hope it's enough clear! Thank you very much! Lisp request.dwg Quote Link to comment Share on other sites More sharing options...
mhupp Posted May 25, 2023 Share Posted May 25, 2023 (edited) Build a selection set of blocks with attributes. for each block step thought each attribute and save the "type" and "manufacturer_code" if type is a matches a predefined list '("Base Cabinets" "Wall Cabinets" "Tall Cabinets") then get a bounding box of the current block. calculate the mid point and create text with the "manufacturer_code" at the mid point. ;;----------------------------------------------------------------------------;; ;; Pull Manufacturer_Code for cabinets and input them center of block (defun C:CAB-Label (/ Drawing ss blk atts att typ man minpt maxpt MPT) (vl-load-com) (setq i 0) (vla-startundomark (setq Drawing (vla-get-activedocument (vlax-get-acad-object)))) (prompt "\nSelect Blocks: ") (while (setq ss (ssget '((0 . "INSERT") (66 . 1)))) ;allows user to make multiple selections (setvar 'cmdecho 0) (foreach blk (mapcar 'vlax-Ename->Vla-Object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) (setq atts (vlax-invoke blk 'getattributes)) (setq typ "" man "") (foreach att atts (cond ((= (vla-get-tagstring att) "Type") (setq typ (vla-get-textstring att)) ) ((= (vla-get-tagstring att) "Manufacturer_Code") (setq man (vla-get-textstring att)) ) ) ) (if (member typ '( "Base Cabinets" "Wall Cabinets" "Tall Cabinets")) ;update list for other blocks (progn (vla-GetBoundingBox blk 'minpt 'maxpt) (setq MPT (mapcar '/ (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt)) '(2 2 2))) (entmake (list '(0 . "TEXT") (cons 10 MPT) (cons 11 MPT) (cons 40 (getvar 'textsize)) (cons 1 man) '(62 . 1) '(72 . 1) '(73 . 2))) (setq i (1+ i)) ) ) ) ) (prompt (strcat "\n" (itoa i) " Cabinets labeled")) ;message at the end (vla-endundomark Drawing) (setvar 'cmdecho 1) (princ) ) Edited May 27, 2023 by mhupp 2 Quote Link to comment Share on other sites More sharing options...
stlo Posted May 26, 2023 Author Share Posted May 26, 2023 Hi mhupp!! Wow! This is awesome! Thank you very much! This is exactly what I was thinking about! It's very helpful! Have a great day! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 26, 2023 Share Posted May 26, 2023 @mhuppFWIW ;; This (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk)))) ;; Returns the same as this (setq atts (vlax-invoke blk 'getattributes)) ;; At least in AutoCAD 2 Quote Link to comment Share on other sites More sharing options...
devitg Posted May 26, 2023 Share Posted May 26, 2023 45 minutes ago, ronjonp said: @mhuppFWIW ;; This (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes blk)))) ;; Returns the same as this (setq atts (vlax-invoke blk 'getattributes)) ;; At least in AutoCAD @ronjonp Would you, please. BLK shal be a vl-obj or an entity? and last but not least which properties can be call form VLAX-INVOKE? Thanks in advance Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 26, 2023 Share Posted May 26, 2023 (edited) 57 minutes ago, devitg said: @ronjonp Would you, please. BLK shal be a vl-obj or an entity? and last but not least which properties can be call form VLAX-INVOKE? Thanks in advance It needs to be a VLA object. I'd imagine any vla-get* could be called but not certain. vla-getX.txt Edited May 26, 2023 by ronjonp Quote Link to comment Share on other sites More sharing options...
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.