Jump to content

numinc for attributes


pmxcad

Recommended Posts

Hello,

Is there a version of Lee Mac's numinc.lsp that can be used with block attributes. So run the lisp, it askes to pick a block, it returs a screen with the question witch tag from the block to use and rest the same as numinc lisp. After that pick the blocks in your order and set the attributes.

 

Thanks,

 

Pmxcad

Link to comment
Share on other sites

NUMBER ATT.gif

 

Here's a good start for you.

 

 
(defun c:test ( / ss->lst ss n )
 (vl-load-com)
 (defun ss->lst ( ss flag / id lst )
   (if (eq 'PICKSET (type ss))
     (repeat (setq id (sslength ss))
       (
         (lambda ( name )
           (setq lst
             (cons
               (if flag (vlax-ename->vla-object name)
                 name
               )lst
             )
           )
         )(ssname ss (setq id (1- id)))
       )
     )
   )
 )
 (if 
   (and 
     (setq ss 
       (ss->lst (ssget '((0 . "insert")(66  . 1))) t)
     ) (setq n 0)
   )
   (foreach x (reverse ss)
     (foreach p (vlax-invoke x 'GetAttributes)
       (if (eq (strcase (vla-get-textstring p)) "T")
         (vlax-put p 'TextString (itoa (setq n (1+ n))))
       )
     )
   )
 ) (princ)
)

Link to comment
Share on other sites

Here is my version:

 

(defun c:AdSel (/ aDoc TagSource ent Blk Var1 Var2)
(vl-load-com)
      (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
       (cond ((and
       (setq TagSource (car (nentselp "\nSelect Attribute: ")))
        (eq (cdr (assoc 0 (setq ent (entget TagSource)))) "ATTRIB")
        (setq Vlt (list (cdr (assoc 2 ent))(cdr (assoc 1 ent))))
        (setq i 0 AtVl (vlax-invoke (setq entV
                               (vla-ObjectIdToObject
                                     aDoc
                                     (vla-get-OwnerId
                                           (vlax-ename->vla-object
                                                 TagSource))
                                     ))
                               'GetAttributes))

         (while (not              
   (and  (eq (vla-get-tagstring (car AtVl)) (car Vlt))
               (eq (vla-get-textstring (car AtVl)) (cadr Vlt))))
          (setq i (1+ i) Atvl (cdr Atvl))
               )
        )
              )
             )
(setq pt1 (getpoint "\nPick Base Point:"))
(while 
      (setq pt2 (getpoint pt1 "\nNext Point"))
          (vlax-invoke (setq NewObj (vla-copy entV)) 'Move pt1 pt2)
        (setq At2Mod (nth i (vlax-invoke NewObj 'GetAttributes))
         str (vla-get-textstring At2Mod)
         crtVal
 (atoi (substr str (+ (strlen (setq prf_t
                          (vl-string-right-trim  "1234567890" str))) 1))))          
 (vla-put-textstring At2Mod (strcat prf_t (itoa (1+ crtVal))))
        (setq pt1 pt2 entv NewObj)
                 )
          )

 

The difference with this one is as you copy the block the attrinbute you select (on prompt) will be the one that increments

 

Hope this helps

Link to comment
Share on other sites

The blocks are already in the drawing, and i want to pick the blocks one by one in my own order. I like the numinc lisp, i can set a frefix, suffix, etc etc...........

 

Pmxcad

Link to comment
Share on other sites

No worries pmxcad, the routine i posted is especially usefull for blocks with multiple attributes but having the same TAG name. and like i said, its different in such a way that it creates new copies of the the block and increments it. i.e.

 

1 to 2

Box12 to Box13

 

Maybe one day i will modify it for existing blocks and add a prompt for suffix/prefix etc..

 

Cheers

Link to comment
Share on other sites

Yep, RENUM.LSP comes very close. But in the numinc lisp from Lee Mac i can also choose alphanummeric characters to start with. I also like the dialogscreen.

So renum.lsp is a good lisp but i like the options in the numinc lisp. Like layer, text high, text border, text style etc.

 

 

PmxCAD

Link to comment
Share on other sites

Oookay,

it shows about everything of that block but i cannot change it. The dcl dialogs.......... lot of information to read and to learn. Ok, takes some time.

 

Thanks

 

Pmxcad

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