Jump to content

Recommended Posts

Posted

hey guys, i need your help, i have couple of problems

 

1. i have more than 400 text that has a field on it (object/coordinate), i want to remove the field am using Autocad 2006 that's why i cant just explode it. do you have any Lisp that i can use to remove the field in from all the text at once.

 

2. i need to insert a block in all the vertices of a polyline, do you have lisp for that?

 

Thanks guys

Posted

For point 1: This is a rather simple lisp. All that needs to happen is to select the texts, then step through each in turn, modify its value to be the same as extracted from its value. That should keep the texts displaying the same, but omit the underlying field codes.

Posted

Inreb, we are talking about 400 plus texts, i can go at every text but i am just asking of a fast way.

 

lee, i'll try your suggestion.

Posted

Lee,

 

I've tried the PtManagerV2-4.lsp, it's really nice, i can use it in my other projects, but i can't use it in my drawings right now.

my problem right now is how to put a block in all the vertices of a polyline.

I am expecting a Lisp that goes like this:

 

1 enter Block Name/or Select Block:

2 Select Polyline:

 

that's it, and the block that i've selected or entered will automatically go to the intersection points(vertices).

kinda' easy,but not for me. i hope you can help me with this

 

thanks

Posted
I've tried the PtManagerV2-4.lsp, it's really nice, i can use it in my other projects, but i can't use it in my drawings right now.

my problem right now is how to put a block in all the vertices of a polyline.

 

You should be able to select Polyline (3D/LW) from the Input list, then Block from the Output list and the program should perform as required.

Posted
Inreb, we are talking about 400 plus texts, i can go at every text but i am just asking of a fast way.
My post was intended to show you what the lisp must do. Anyhow, here's a "quick" hash of exactly what I meant:
(vl-load-com)

(defun c:RemoveFields (/ ss n en ed new)
 (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) ;Only continue if there's text / mtext selected
   (progn ;Group the following lines into the then portion of the if
     (setq n (sslength ss)) ;Get the number of selected texts
     (while (>= (setq n (1- n)) 0) ;Loop through all items inside the selection set
       (setq en (ssname ss n) ;Get the nth item in the selection set
             ed (entget en) ;Get its DXF data list
       )
       (entmod ;Modify the entity
         (vl-remove-if-not ;Remove not needed items from the DXF list
           '(lambda (item) (member (car item) '(-1 1 3))) ;Only items starting with -1, 1 or 3
           ed
         )
       )
     )
   )
 )
 (princ) ;End without displaying anything on the command line
)

Posted

Check this out for inserting a block at every vertices of a polyline ...

 

(defun c:TesT (/ Bname b e i lst)
 ;; Tharwat 06. Oct. 2011 ;;
 (if (and
       (setq Bname (getstring T "\n Enter Block name :"))
       (setq b (tblsearch "BLOCK" Bname))
       (setq e (car (entsel "\n Select a polyline :")))
     )
   (progn
     (setq i   0
           lst (vl-remove-if-not
                 (function (lambda (x)
                             (eq (car x) 10)
                           )
                 )
                 (entget e)
               )
     )
     (repeat (length lst)
       (entmakex (list '(0 . "INSERT")
                       (cons 2 Bname)
                       (nth i lst)
                       '(41 . 1.)
                       '(42 . 1.)
                       '(43 . 1.)
                       '(50 . 0.)
                 )
       )
       (setq i (1+ i))
     )
   )
   (cond
     ((or (eq Bname nil) (eq Bname ""))
      (princ "\n Block name is nil ")
     )
     ((not b) (princ "\n Block name is not existed !!"))
     (t
      (Princ
        "\n You must have missed the polyline or it's not Polyline !!!"
      )
     )
   )
 )
 (princ)
)

 

Tharwat

Posted

Lee, the PtManagerV2-4.lsp works well, the same way as Tharwat's lisp, but i am expecting the rotation of the block to be relative to the polyline, like a chainage tick that rotates as the polyline changes direction.

 

 

irneb, the lisp load succesfully but it didn't removed the field from the text.

 

thank you so much guys!

Posted
Lee, the PtManagerV2-4.lsp works well, the same way as Tharwat's lisp, but i am expecting the rotation of the block to be relative to the polyline, like a chainage tick that rotates as the polyline changes direction.

 

See this thread.

Posted
irneb, the lisp load succesfully but it didn't removed the field from the text.
OK, try this one then ... strange that entmod doesn't want to get rid of the field.
(vl-load-com)

(defun c:RemoveFields (/ ss txt)
 (if (ssget '((0 . "TEXT,MTEXT"))) ;Only continue if there's text / mtext selected
   (progn ;Group the following lines into the ten portion of the if
     ;; Get the ActiveX selection set
     (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))))
     (vlax-for eo ss ;Step through all objects in the selection set
       (setq txt (vla-get-TextString eo)) ;Get the currently displayed text
       (vla-put-TextString eo "") ;Set the current text to empty
       (vla-put-TextString eo txt) ;Replace the text without the field
     )
     (vla-Delete ss) ;Clear the selection set from RAM
   )
 )
 (princ) ;End without displaying anything on the command line
)

It "shouldn't" be necessary to clear the text first, but I've added that in just in case!

 

Note though, I've had to use the ActiveX stuff. Which means you might have problems with unicode characters.

Posted

Lee, Tharwat, Inreb,

 

the lisps works perfectly, the work that requires 24 manhours is done in 6hours.

 

guys, because of CadTutor, my boss notices my work, positive feedbacks are pouring, and i just dont want to take the credits for myself, I OWE IT TO YOU, thanks for the help.:D

Posted

You're welcome JORYROJ .

 

I am glad that you liked the codes . :)

 

Tharwat

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