Jump to content

Recommended Posts

Posted (edited)

I found on the forum some Thread about this theme, but I´m ultra

beginner in AutoLISP so i need advice from the beginning. I´m trying

to add text and delete text from a block, but not all, only concrete

part. Can u help me pls? Any help would be appreciated. Thanks

Edited by AntresSon
  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • AntresSon

    11

  • Tharwat

    10

  • BrianTFC

    1

Posted

Welcome to CADTutor .

 

I think we can help you if you explain your idea clearly and in details .

Posted

upnisito.cz/view.php?filename=8471.png

Posted

Upload a sample drawing if you can .

 

Are you talking about attribute definition ? or just a text object ?

Posted

Okey ... On the left side, i need to add this text automatically and on the right side text ,, a.s. BYTČA" in a block i need to remove automatically

 

File upload:

 

http://leteckaposta.cz/593426502

Posted
Can somebody help me pls? :(

 

I am sorry , I am completely forgot about this thread :(

 

Anyway , here a routine to delete any text in/out side block definition .

 

(defun c:deltxt  (/ s)
 ;; Tharwat 28.4.2015	;;
 (if
   (and (setq s (nentsel "\nPick Text to delete [even in Block] :"))
        (wcmatch (cdr (assoc 0 (entget (setq s (car s))))) "*TEXT")
        (vlax-write-enabled-p (setq s (vlax-ename->vla-object s)))
        (not (vla-delete s))
        (vlax-erased-p s)
        )
    (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object))
               acAllViewports)
    )
 (princ)
 )(vl-load-com)

 

But to add text or any entity to a block , we should know the insertion point coordinates that is related to the block definition itself .

Posted (edited)

No add text to a block. I need to remove text from a block ,,a.s. BYTČA" , together with add text (red font) on the left side of the sample file which I sent => (http://leteckaposta.cz/593426502). Pls, can u create complete code for my? Thanks Sir! :notworthy:

Edited by AntresSon
Posted

Okay ,

 

Do you have many Attributed blocks in your drawing or just one block ?

You want to remove the same text a.s. BYTČA ONLY ?

The text in red color would be added in the same location as it is now with the current block to the other attributed blocks ?

Posted

ad 1. I have one block only

ad 2. Yep, i want to remove a.s. BYTČA only

ad 3. Yep, text would be added in the same location as it is now

Posted

I don't know why you want a lisp since the maximum steps you want to do is just two , use the program that I wrote for you in this thread on the text in any block or text string , and copy with base point that text in red and paste in many locations as mush as you want .

 

It does it need a lisp at all in my opinion .

Posted

AntresSon,

 

if all you are doing is replacing one word or two words with another then just use the FIND command that is already in AutoCAD.

 

Brian,

Posted

My problem is, that I have a lot of drawing files (about 6K) and I have to change these files automatic with adding red text together with deleting a text ,,a. s. Bytča"

Posted
My problem is, that I have a lot of drawing files (about 6K) and I have to change these files automatic with adding red text together with deleting a text ,,a. s. Bytča"

 

Select the red text that you want to copy to every drawing then right click and choose ClipBoard -> Copy with base point then pick your base point .

Now open every drawing use my previous posted program in this thread to delete the text in the block then use Cntl+V to paste the red text into your desired base point .

 

Very easy :)

Posted

But 6000 drawing files ... It´s a huge volume ... So I though that it is possible, I open drawing file => run AutoLisp code => close drawing file, and that´s all... So okey, anyway, Thanks very much for your time

Posted

Okay , let us get back to it and write a complete program to delete that specific text from that specific Attributed block .

 

NOTE: the red text that you want to add is a block reference in that attached drawing , is it okay with to make it a text object instead of a block ?

Posted (edited)

Anyway , try this program and let me know how you get on with it .

 

(defun c:Test (/ s)
 ;; Tharwat 29.4.2015	;;
 (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "raz-1-a"))))
   (progn
     ((lambda (i / sn nx e d)
        (while (setq sn (ssname s (setq i (1+ i))))
          (setq nx (tblobjname "BLOCK" (cdr (assoc 2 (entget sn)))))
          (while (setq nx (entnext nx))
            (setq d (vlax-ename->vla-object nx))
            (if
              (or
                (and
                  (wcmatch (cdr (assoc 0 (setq e (entget nx))))
                           "*TEXT"
                  )
                  (eq (cdr (assoc 1 e)) "a.s.BYTCA")
                  (vlax-write-enabled-p d)
                )
                (and (eq (cdr (assoc 0 (setq e (entget nx)))) "LINE")
                     (equal
                       (distance (cdr (assoc 10 e)) (cdr (assoc 11 e)))
                       0.71
                       1e-2
                     )
                     (vlax-write-enabled-p d)
                )
              )
               (vla-delete d)
            )
          )
        )
      )
       -1
     )
     (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object))
                acAllViewports
     )
     (mapcar
       '(lambda (s p)
          (entmake
            (list
              '(0 . "TEXT")
              '(8 . "KOT")
              (cons 10 p)
              (cons 11 p)
              '(40 . 2.0)
              (cons 1 s)
              '(50 . 1.5708)
              '(41 . 1.0)
              '(51 . 0.0)
              (cons 7
                    (if (tblsearch "STYLE" "ROMANS")
                      "ROMANS"
                      (getvar 'TEXTSTYLE)
                    )
              )
              '(71 . 0)
              '(72 . 0)
              '(73 . 0)
            )
          )
        )
       (list
         "THIS DRAWING CONTAINS CONFIDENTIAL INFORMATION AND IS INTANGIBLE PROPERTY OF KINEX BEARINGS a.s. COMPANY."
         "WITHOUT WHOSE PERMISSION IT MAY NOT BE COPIED OR HANDED TO A THIRD PARTY"
       )
       (list '(24.0298 61.0431 0.0)
             '(27.5298 61.0697 0.0)
       )
     )
   )
 )
 (princ)
)(vl-load-com)

Edited by Tharwat
Posted

Sorry, bud I didn´t know, that you replied, bc i didn´t get email notice... THANKS, it works! But, there is still ,,V" in a block after deleting. It´s created using lines...

Posted

I updated the codes in post no# 18 . try it and let me know .

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