Jump to content

Attributes value combine of text and unqiue number


rajapower

Recommended Posts

hi

 

Hi

 

This is my first post in this awesome forum. I’ m raja in drafting

Kindly help me with a lisp program. That

Asks the user to select various blocks in the drawing

Places an attribute text over the value combine of text and unique no.

Makes an attribute value with that att texts and sequence no.

The values of the att block should contain the blocks

Note: The tag name should be have a ID of tags in that value is (EXAMPLE : L00-350-01-EPC-6QE-01 (in end of the value change each block)

 

for refer i attached the sample file of attributes

 

Please help me. Daily I have to spend one hell of time in this work .Text with number.dwg

Link to comment
Share on other sites

In general what you are trying to do is doable but we need more details about the process and the outcome of the program to be able to write something useful .

The two uploaded drawings are the same in contents , aren't they ?

I could not see any difference and you might did uploaded two copies by mistake unless you have something important that you did forget to mention !

Link to comment
Share on other sites

In general what you are trying to do is doable but we need more details about the process and the outcome of the program to be able to write something useful .

The two uploaded drawings are the same in contents , aren't they ?

I could not see any difference and you might did uploaded two copies by mistake unless you have something important that you did forget to mention !

thks for reply, sorry the files uploaded twices...

Link to comment
Share on other sites

i need to fill the attribute value in the block syntax of attribute tag is "ID" in that unique value to update the each attribute block, like each block should have been sequence no. Ex: L00-350-01-EPC-6QE-01 in this (end of the value to change each block) that means next block once to pick i need to get sequence no of L00-350-01-EPC-6QE-02

Link to comment
Share on other sites

So you want the program to ask the user to specify the first increment number then after select a bunch of attributed blocks, the program should combine the current text string in the ID tag name with the new increment number ?

 

Is that what you are after ?

Link to comment
Share on other sites

i have number incrementally but in that i need the string also. fYR the lisp

 

(defun c:UPNUMBER (/ tagname addno ss en an ad ch)

 

(setq tagname "ID")

 

(or def_addno (setq def_addno 1))

(initget 6)

(setq addno (getint (strcat "\nStarting Number

 

(itoa def_addno)

">: "

)

)

)

(or addno (setq addno def_addno))

 

(and (setq ss (ssget '((0 . "INSERT") (66 . 1))))

(while (setq en (ssname ss 0))

(setq an (entnext en)

ad (entget an)

ch nil

)

(while (and (= "ATTRIB" (cdr (assoc 0 ad)))

(not ch)

)

(and (= (strcase tagname)

(strcase (cdr (assoc 2 ad)))

)

(setq ch T)

(entmod (subst (cons 1 (itoa addno))

(assoc 1 ad)

ad

)

)

(setq addno (1+ addno))

)

(setq an (entnext an)

ad (entget an)

)

)

(if ch

(entupd en)

(progn

(redraw en 3)

(alert "ID Tag Not Found In This Block")

(redraw en 1)

)

)

(ssdel en ss)

)

)

(setq def_addno addno)

(prin1)

)

Link to comment
Share on other sites

This ?

 

(defun c:Test (/ v lst n s ss)
 ;;------------------------------------;;
 ;;	Tharwat 03.06.2015		;;
 ;; Increment with a number entered	;;
 ;; by a user if the tag string is ID	;;
 ;;------------------------------------;;
 (if
   (and (setq v (getstring
                  "\nSpecify String with integer number at the end :"
                )
        )
        (if (setq lst (_parseInt v))
          (setq n (read (car lst))
                s (cadr lst)
          )
          (progn
            (alert
              "\nEntered value must have integer number at the end !"
            )
            nil
          )
        )
        (princ "\nSelect Attributed Block that have ID tag name :")
        (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
   )
    ((lambda (i / sn)
       (while (setq sn (ssname ss (setq i (1+ i))))
         (mapcar
           '(lambda (a)
              (if (eq (strcase (vla-get-tagstring a)) "ID")
                (progn
                  (vla-put-textstring
                    a
                    (strcat s
                            (if (< n 10)
                              (strcat "0" (itoa n))
                              (itoa n)
                            )
                    )
                  )
                  (setq n (1+ n))
                )
              )
            )
           (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)
         )
       )
     )
      -1
    )
 )
 (princ)
)(vl-load-com)
(defun _parseInt (v / l)
 (setq v (vl-list->string (reverse (vl-string->list v))))
 (while (and v (numberp (read (setq n (substr v 1 1)))))
   (setq l (cons n l)
         v (substr v 2)
   )
 )
 (if l
   (list (apply 'strcat l)
         (vl-list->string (reverse (vl-string->list v)))
   )
 )
)

Edited by Tharwat
Link to comment
Share on other sites

thks for your reply,

 

your given in the lisp is only having the integer value only accepting. but i need with string and integer value ex : L03-314-01-EPC-6QR-01 upto highlighted in red text (string) is remaining same in end the number (integer) value alone will be increment the value.

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