Jump to content

Copying and Increasing attributes


bagulhodoido

Recommended Posts

Hi there.

 

Is there anyway to increase an atributte when copying some text. Like, I oftenly need to number walls on drawings. So, like, I copy the text EW 01 (exterior wall 01) and when I paste it, I want it to become EW 02.

 

Thanks for your help.

Link to comment
Share on other sites

Hi there.

 

Is there anyway to increase an atributte when copying some text. Like, I oftenly need to number walls on drawings. So, like, I copy the text EW 01 (exterior wall 01) and when I paste it, I want it to become EW 02.

 

Thanks for your help.

 

I use this:

 

;;; Replaces selected attribute value with new one and adds sequential number at the end
;;; Author paulmcz Copyright© 2006

(defun c:qs (/ ans st nw oerr e1 e2 natt)
 (setq oerr *error*)
 (defun *error* (msg)
   (princ "\n ERROR!")
   (setq *error* oerr)
   (command)
   (princ)
 )
 (if ns
   (princ (strcat "\n Previous text = " ns (itoa stt)))
 )
 (if ns
   (setq
     ans (getstring
    "\n Keep previous text? [ENTER = yes]: "
  )
   )
 )
 (if (= ans "")
   ()
   (setq ns nil
  st nil
   )
 )
 (if ns
   ()
   (setq ns (getstring t "\n Type in new text: "))
 )
 (if stt
   ()
   (setq stt 1)
 )
 (princ "\n Start with number < ")
 (princ stt)
 (princ " >?: ")
 (setq st (getint))
 (if (= st nil)
   (setq st stt)
   (setq stt st)
 )
 (setq nw (strcat ns (itoa st)))
 (setq e1 (nentsel "\n Select attribute, do not miss: "))

 (while e1
   (setq e2 (entget (setq natt (car e1))))
   (entmod (subst (cons 1 nw) (assoc 1 e2) e2))
   (entupd natt)
   (if	(eq (cdr (assoc 0 e2)) "ATTRIB")
     (setq st (+ 1 st))
     (princ "\n You missed! ")
   )
   (if	st
     (setq nw	(strcat ns (itoa st))
    stt	st
     )
   )
   (setq e1 (nentsel "\n Select next attribute or [ENTER] to exit: "))
 )
 (princ)
)

(prompt "\n Type > qs < to update attributes: ")

 

It is not made for copy & paste but it works the similar way. Try it.

Link to comment
Share on other sites

I use this:

 

;;; Replaces selected attribute value with new one and adds sequential number at the end
;;; Author paulmcz Copyright© 2006

(defun c:qs (/ ans st nw oerr e1 e2 natt)
 (setq oerr *error*)
 (defun *error* (msg)
   (princ "\n ERROR!")
   (setq *error* oerr)
   (command)
   (princ)
 )
 (if ns
   (princ (strcat "\n Previous text = " ns (itoa stt)))
 )
 (if ns
   (setq
     ans (getstring
       "\n Keep previous text? [ENTER = yes]: "
     )
   )
 )
 (if (= ans "")
   ()
   (setq ns nil
     st nil
   )
 )
 (if ns
   ()
   (setq ns (getstring t "\n Type in new text: "))
 )
 (if stt
   ()
   (setq stt 1)
 )
 (princ "\n Start with number < ")
 (princ stt)
 (princ " >?: ")
 (setq st (getint))
 (if (= st nil)
   (setq st stt)
   (setq stt st)
 )
 (setq nw (strcat ns (itoa st)))
 (setq e1 (nentsel "\n Select attribute, do not miss: "))

 (while e1
   (setq e2 (entget (setq natt (car e1))))
   (entmod (subst (cons 1 nw) (assoc 1 e2) e2))
   (entupd natt)
   (if    (eq (cdr (assoc 0 e2)) "ATTRIB")
     (setq st (+ 1 st))
     (princ "\n You missed! ")
   )
   (if    st
     (setq nw    (strcat ns (itoa st))
       stt    st
     )
   )
   (setq e1 (nentsel "\n Select next attribute or [ENTER] to exit: "))
 )
 (princ)
)

(prompt "\n Type > qs < to update attributes: ")

It is not made for copy & paste but it works the similar way. Try it.

 

 

Thanks man.

 

Btw, what am I supposed to select (and NOT MISS) when it prompts to select the attributes?

 

I thought it was the text string so It would keep the desired style, but whenever I select the strings it prompts a "You missed!"

Link to comment
Share on other sites

Select attribute value to be updated or changed

 

Hmm, But what am I doing wrong?

 

I select the text string I want to update and it says You missed!

 

It does change the string for, in my case, EW1, but the next string I select becomes EW1 again and so it goes.

 

I wanted it to be like, first one EW1, next string, EW2. You know, like that.

 

That's how it works right?

Link to comment
Share on other sites

The green texts in the title block in the attached drawing are all attributes. If you start the routine and click on any of the green text, it should update with any next one having incremented number at the end. Try it and let me know if it works with the attached drawing.

10DX05,5HX2LXMELRWA32959.dwg

Link to comment
Share on other sites

The green texts in the title block in the attached drawing are all attributes. If you start the routine and click on any of the green text, it should update with any next one having incremented number at the end. Try it and let me know if it works with the attached drawing.

 

Oh, that's what you ment by attributes.

 

Hm, I don't really know how to manage them. I'll look on Autocad help files about creating blocks with attributes.

 

Thanks for your help.

Link to comment
Share on other sites

If you just want to insert annotation incremental text, try my numbering routine. Read first few lines in the code, to see what it does.

 

Exactly what I wanted. Amazing lisp.

 

Thanks for your help.

Link to comment
Share on other sites

  • 1 year later...

Hi Paul, firstly thanks for the lisp routine, it's great and very useful.

One question though, I used it to incrementally number blocks on my drawings representing pile foundations. These often number into the 100's so when prompted with "start with number?" I entered 001 but the 0's were left out when I clicked on the attributes. Is there a way for the number to keep the 0's at the beginning? The 0's make the numbers list in order when I run a data extraction to create a piling table.

 

Make sense? Cheers in advance.

Link to comment
Share on other sites

  • 1 year later...
If you just want to insert annotation incremental text, try my numbering routine. Read first few lines in the code, to see what it does.

 

thanks for the lisp, i found it very helpful. Is it possible for u to edit the routine so that annotation incremental text gets aligned to curves and lines.

Link to comment
Share on other sites

  • 4 years later...

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