enthralled Posted February 25, 2022 Posted February 25, 2022 (edited) Hi, I have 4 block names: AHS-1T, AHS-1TR, AHS-2T, AHS-2TR They all have a text attribute called "TEE", with different values (e.g. N2096) I have many of these 4 block types scattered, each having a distinct TEE attribute value, on the other hand, I have a table where there are text objects having the same contents as the TEE attribute. What I need is for the blocks to move to the position of the text which have the same content as the TEE value (eg block with Tee attribute "N2096" will move to the position of the text object which also reads "N2096". Attached CAD Source and result for reference. EDIT: just a tiny clarification, the block insertion point will match the X position of the text, but the Y position will be 148 units below the text. (although I can offset the Y position manually, so it's not a big deal). Thanks Source.dwg Result.dwg Edited February 25, 2022 by enthralled Quote
marko_ribar Posted February 25, 2022 Posted February 25, 2022 Good trick with hiding TEXT entities... But why are you lying with your Result.dwg... Your TEXT entites are on higher position than your placements of blocks... So, I unhide them all... Result-N.dwg Source-N.dwg Quote
mhupp Posted February 25, 2022 Posted February 25, 2022 Don't know if you have multiple graphs so this will ask you to pick the "Row" to get the Y cords. x cords are pulled form the text. then its just a simple move command. will display an error message if either multiple text are found or no text are found. ;;----------------------------------------------------------------------------;; ;; Move Blocks to graph location (defun C:BlkMove (/ x y ss txt blk atts oTag) (setq y (cadr (getpoint "\nPick \"SPECIAL PIECES\" Row"))) (prompt "\nSelect Blocks") (setvar 'cmdecho 0) (if (setq ss (ssget '((0 . "INSERT") (2 . "AHS-1T,AHS-1TR,AHS-2T,AHS-2TR") (66 . 1) (410 . "Model")))) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq PT (cdr (assoc 10 (entget blk)))) (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes (vlax-ename->vla-object blk))))) (foreach tag atts (if (eq (vla-get-tagstring tag) "TEE") (progn (setq oTag (vla-get-textstring tag)) (if (setq txt (ssget "_X" (list '(0 . "*TEXT") (cons 1 oTag) '(410 . "Model")))) (if (eq (sslength txt) 1) (progn (setq x (car (cdr (assoc 10 (entget (ssname txt 0)))))) (vl-cmdf "_.Move" blk "" "_non" PT "_non" (list x y)) ) (prompt (strcat "\nMultiple Text Found [" oTag "]")) ) (prompt (strcat "\nText not Found [" oTag "]")) ) ) ) ) ) ) (setvar 'cmdecho 1) (princ) ) 1 Quote
marko_ribar Posted February 25, 2022 Posted February 25, 2022 Just saw this : Quote EDIT: just a tiny clarification, the block insertion point will match the X position of the text, but the Y position will be 148 units below the text. (although I can offset the Y position manually, so it's not a big deal). Thanks Sorry for my bad insight and reaction... 1 Quote
enthralled Posted February 28, 2022 Author Posted February 28, 2022 (edited) On 2/25/2022 at 6:50 PM, mhupp said: Don't know if you have multiple graphs so this will ask you to pick the "Row" to get the Y cords. x cords are pulled form the text. then its just a simple move command. will display an error message if either multiple text are found or no text are found. ;;----------------------------------------------------------------------------;; ;; Move Blocks to graph location (defun C:BlkMove (/ x y ss txt blk atts oTag) (setq y (cadr (getpoint "\nPick \"SPECIAL PIECES\" Row"))) (prompt "\nSelect Blocks") (setvar 'cmdecho 0) (if (setq ss (ssget '((0 . "INSERT") (2 . "AHS-1T,AHS-1TR,AHS-2T,AHS-2TR") (66 . 1) (410 . "Model")))) (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) (setq PT (cdr (assoc 10 (entget blk)))) (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes (vlax-ename->vla-object blk))))) (foreach tag atts (if (eq (vla-get-tagstring tag) "TEE") (progn (setq oTag (vla-get-textstring tag)) (if (setq txt (ssget "_X" (list '(0 . "*TEXT") (cons 1 oTag) '(410 . "Model")))) (if (eq (sslength txt) 1) (progn (setq x (car (cdr (assoc 10 (entget (ssname txt 0)))))) (vl-cmdf "_.Move" blk "" "_non" PT "_non" (list x y)) ) (prompt (strcat "\nMultiple Text Found [" oTag "]")) ) (prompt (strcat "\nText not Found [" oTag "]")) ) ) ) ) ) ) (setvar 'cmdecho 1) (princ) ) Thanks for the help! Also special thanks for allowing me to pick the row for the special pieces. This is so neat Edited February 28, 2022 by enthralled 1 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.