Marius_ Posted September 27, 2019 Share Posted September 27, 2019 Hi. Anyone could help me? I need to replace text objects with a block (same insertion point), get the value (plus a factor - which is secondary) from text and apply it on the X scale, including negative values . Thanks in advance Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 28, 2019 Share Posted September 28, 2019 Hi, Can you upload a sample drawing saved up to CAD 2017 as an example including the attributed block ? What do you mean by factor ? Is it a suffix / prefix or what? Quote Link to comment Share on other sites More sharing options...
Marius_ Posted September 28, 2019 Author Share Posted September 28, 2019 Hi, Its not an attributed block. Forget the factor. Here is my sample. Thanks Sample1.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 28, 2019 Share Posted September 28, 2019 (defun c:Test ( / sel int ent ) ;; Tharwat - Replace texts with blocks. ;; (and (or (tblsearch "BLOCK" "1") (alert "Block name < 1 > was not found in current drawing <!>") ) (princ "\nSelect text to replace with block name < 1 > :") (setq int -1 sel (ssget "_:L" '((0 . "*TEXT")))) (while (setq int (1+ int) ent (ssname sel int)) (and (entmake (list '(0 . "INSERT") (assoc 10 (entget ent)) '(2 . "1") '(50 . 0.0))) (entdel ent) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Marius_ Posted September 28, 2019 Author Share Posted September 28, 2019 Hi. Your code replace the text but for some reason dont aplly the text value at x Scale (and i cant understand if the code was supposed to do that). Thanks anyway! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 28, 2019 Share Posted September 28, 2019 32 minutes ago, Marius_ said: Your code replace the text but for some reason dont aplly the text value at x Scale (and i cant understand if the code was supposed to do that). No it was not, hence here is the one that does so. (defun c:Test ( / sel int ent get fac) ;; Tharwat - Replace texts with blocks. ;; (and (or (tblsearch "BLOCK" "1") (alert "Block name < 1 > was not found in current drawing <!>") ) (princ "\nSelect text to replace with block name < 1 > :") (setq int -1 sel (ssget "_:L" '((0 . "*TEXT")))) (while (setq int (1+ int) ent (ssname sel int)) (and (setq get (entget ent)) (numberp (setq fac (distof (cdr (assoc 1 get))))) (entmake (list '(0 . "INSERT") (assoc 10 get) '(2 . "1") '(50 . 0.0) (cons 41 fac) '(42 . 1.0) '(43 . 1.0))) (entdel ent) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Marius_ Posted September 28, 2019 Author Share Posted September 28, 2019 It does what i want! Thanks!! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 28, 2019 Share Posted September 28, 2019 You're welcome anytime. 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.