Jump to content

Replace text with block and transfer value to scale X


Recommended Posts

Posted

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

Posted

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?

Posted
(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)
  )

 

Posted

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!

Posted
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)
  )

 

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