Jump to content

How to copy text into multi blocks


Hagar Mohamed

Recommended Posts

Hi, 

I need lisp to copy letter into base point of multi blocks at the same time,

As this image 

image.png.7750999435abd03c427c7ea63be2543d.png

Sorry for my bad English, I am not native speaker. 

Link to comment
Share on other sites

I'm sure Lee mac has a copy text somewhere on this / his site but maybe post a dwg file so people know the structure of your blocks.

  • Like 1
Link to comment
Share on other sites

2 hours ago, rlx said:

I'm sure Lee mac has a copy text somewhere on this / his site but maybe post a dwg file so people know the structure of your blocks.

 

i use that all the time, one of my favourites.... Select a text and it will copy it into any other text you select, selecting the texts one at a time with the mouse, or multiple texts. Problem might be if for example here the blocks don't have the attribute filled in (and so no text to copy into). Has an option to copy to multiple texts ( Copy or Swap Text | Lee Mac Programming (lee-mac.com ). Works well if it is just text you want to change.

 

If the text you want to change is an attribute in the block you can also look at Lee Macs MacAttedit routine, selecting "Current Drawing" option. This gets around having an empty attribute in a block ( Global Attribute Extractor & Editor | Lee Mac Programming (lee-mac.com ) 

 

(not staking his website, but he has some fantastic stuff on there, as full LISPS and also to try to work out what he does and learn from his codes)

 

 

However if there is nothing there where you want your text - no text or attributes - I can't remember seeing that and someone might help you write something (sorry... sunny here today, going to go for a walk this afternoon)

Link to comment
Share on other sites

Maybe Hagar just wants to place a text near every insertion point for a couple of blocks and no poor little attributes have to be hurt for this , I dunno , that's why I would like to see a dwg or someting , like have all blocks same props like size & rotation etc.

Link to comment
Share on other sites

in case Hagar wants text , just for fun :

(defun c:t1 ( / pt1 pt2 sel ss e b l s q h cnt)
  (if (setq pt1 (getpoint "\nPick block to tag or corner point for block selection : "))
    (if (and (setq sel (nentselp pt1))(caddr sel)(setq e (last (last sel)))(= "INSERT" (cdr (assoc 0 (setq b (entget e))))))
      (setq ss (ssget "x" (list (cons 0 "INSERT")(cons 2 (cdr (assoc 2 b))))))
      (if (setq pt2 (getcorner pt1 "\nSelect 2nd corner : "))(setq ss (ssget "C" pt1 pt2 '((0 . "INSERT")))))
    )
  )
  (if ss
    (progn
      (setq cnt 0 l (sort-ss-y ss))
      (setq s (getstring "\nEnter string for insertion point (* = count) : "))
      (setq q (getint "\n0,1,2,3 or 4 for quadrant : "))
      (setq h (getreal "\ntext height : "))
      (foreach x l (create_txt (create_ip (getip x) q h) (create_str s) h)
        
      )
    )
  )
  (princ)
)

(defun getIP (e)(if (= 'ename (type e)) (cdr (assoc 10 (entget e)))))
(defun create_txt (p s h)(entmake (list '(0 . "TEXT")(cons 10 p)(cons 1 s)(cons 50 0.0)(cons 40 h))))
(defun create_ip (p q d)(if (= q 0) p (polar p (* pi (/ (nth q '(0 45 135 225 315)) 180.0)) d)))
(defun create_str (s)(if (eq s "*")(itoa (setq cnt (1+ cnt))) s))
(defun sort-ss-y (ss / e l) ; Xmin -> Xmax + Ymax -> Ymin (UL -> BR)
  (while (setq e (ssname ss 0))(setq l (cons (list (caddr (assoc 10 (entget e))) e) l))(ssdel e ss))
  (mapcar 'cadr (vl-sort l '(lambda (a b) (> (car a)(car b))))))
Edited by rlx
Link to comment
Share on other sites

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