Author Topic: renumbering block attributes  (Read 8044 times)

0 Members and 1 Guest are viewing this topic.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
renumbering block attributes
« Reply #15 on: August 20, 2005, 07:02:38 AM »
Quote from: ELOQUINTET
jurg yours does not do what i want.
Of course does my program what you want and also a lot more.
Quote from: ELOQUINTET
my boss got pissed at me when i told her i got it from somebody because she wanted me to use it as an exercise. i feel kinda bad because she's right but i was sure someone had done and i'm still accustomed to begging.
That's your problem if you adorn oneself with borrowed plumes. The main problem in this case, let's face it, is that my published programms are copyright and that's visible...
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

whdjr

  • Guest
renumbering block attributes
« Reply #16 on: August 21, 2005, 02:25:28 PM »
Quote from: ELOQUINTET
yours of course will. that does exactly what i want. jurg yours does not do what i want. this is not for doing bubbles. look at my posted drawing. my boss got pissed at me when i told her i got it from somebody because she wanted me to use it as an exercise. i feel kinda bad because she's right but i was sure someone had done and i'm still accustomed to begging.
I'm glad I could help you E.  Next time if you tell everyone this is a learning exercise and to not post finished code then we can just give you hints and good practice methods.

ELOQUINTET

  • Guest
renumbering block attributes
« Reply #17 on: August 29, 2005, 10:36:41 AM »
i ran into a couple of snags with will's routine and was wondering if anyone could help me improve it. first i would like it to prompt the user for the attribute name so it would work universally instead of on a single block. secondly i would like to modify it so the user selects the attributes in the order they want and it numbers them all at once not with each pick. this last one is a request from my boss. any takers???

Code: [Select]
(defun c:attnumb (/ ref tobj tstr ttag sel)
 ;
  (defun *get_atts* (obj)
    (vlax-safearray->list
      (vlax-variant-value
   (vla-getattributes
     (if (eq (type obj) 'ENAME)
       (vlax-ename->vla-object obj)
       obj
     )
   )
      )
    )
  )
 ;
  (defun *find*   (attlist nlst)
    (vl-remove-if-not
      '(lambda (x)
    (vl-remove-if-not
      '(lambda (y)
         (eq (vla-get-tagstring x) y)
       )
      nlst
    )
       )
      attlist
    )
  )
 ;
  (defun *put* (obj str lst)
    (mapcar '(lambda (x)
          (vl-catch-all-apply
       'vla-put-textstring
       (list (rt:remove obj x) str)
          )
        )
       lst
    )
  )
 ;
  (defun rt:remove (obj str)
    (car
      (vl-remove-if-not
   '(lambda (x)
      (eq (vla-get-tagstring x) str)
    )
   (*get_atts* obj)
      )
    )
  )
 ;
  (if (and (setq ref (car (entsel "\nSelect reference block:  ")))
      (eq "INSERT" (cdr (assoc 0 (entget ref))))
      )
    (progn
      (setq tobj (car (*find* (*get_atts* ref) '("NUMB")))
       tstr (vla-get-textstring tobj)
       ttag (vla-get-tagstring tobj)
      )
      (while tstr
   (setvar "ErrNo" 0)
   (if
     (not
       (setq sel (car (entsel "\nSelect attribute to update:  ")))
     )
      (if (/= 52 (getvar "ErrNo"))
        (princ "\nNo object selected, please try again: ")
        (progn
          (princ "\nRight click detected - Terminate program. ")
          (setq tstr nil)
        )
      )
      (cond ((not (setq tstr (itoa (1+ (atoi tstr))))))
       ((eq ttag "NUMB") (*put* sel tstr '("NUMB")))
      )
   )
      )
    )
    (*error* (princ "\nNothing selected.  *INVALID*"))
  )
)

whdjr

  • Guest
renumbering block attributes
« Reply #18 on: August 29, 2005, 11:17:33 AM »
Quote from: ELOQUINTET
... first i would like it to prompt the user for the attribute name so it would work universally instead of on a single block.

Dan,
The tool already prompts you to select a block.  It could be modified to allow the user to select a block or input a block name.  However to make it truely universal all your attributes would have have the same tagname.
Quote from: ELOQUINTET
secondly i would like to modify it so the user selects the attributes in the order they want and it numbers them all at once not with each pick. this last one is a request from my boss. any takers???

This could be done however I would like to know why, just curious?   :)

ELOQUINTET

  • Guest
renumbering block attributes
« Reply #19 on: August 29, 2005, 12:12:02 PM »
will what i was trying to say is it would ask for the block name and attribute name so it could be used for any block. i agree that the second opiton is not neccesary but i think we have some other tools which behave this way so she is just used to it behaving that way. that's my guess anyway. any thoughts