Author Topic: adding a prefix to many existing attributes  (Read 4558 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
adding a prefix to many existing attributes
« on: October 10, 2005, 09:57:52 AM »
i have a location plan which has alot of numbered motors. it has been suggested to me that it would be better to number my motors by floor. so my attribute would need to change from 16 to 2.16  . does anyone have something that could do this?

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: adding a prefix to many existing attributes
« Reply #1 on: October 10, 2005, 10:12:09 AM »
I could do it in VBA if you want
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

LE

  • Guest
Re: adding a prefix to many existing attributes
« Reply #2 on: October 10, 2005, 10:22:40 AM »
Here is a good start:

http://www.theswamp.org/forum/index.php?action=search2

It may be there something already done...

Good luck.

ELOQUINTET

  • Guest
Re: adding a prefix to many existing attributes
« Reply #3 on: October 10, 2005, 10:38:54 AM »
i found this topic which i think will do what i want. i modified it but can't get it to work. what did i do wrong? CmdrDuh refresh my memory how do i load vba  :lol:


http://www.theswamp.org/forum/index.php?topic=3813.0

here's the modified code:

Code: [Select]
(defun c:attpref (/ ent entlist newnext newnum newpre next)
 (if (not *num*)(setq *num* 1))
 (if (not *numpre*)(setq *numpre* "A"))
 (setq newpre (getstring (strcat "\nMotor prefix (" *numpre* "): ")))
 (if (not (eq newpre ""))(setq *numpre* newpre))
 (setq newnum (getint (strcat "\nNumber to start with (" (itoa *motnum*) "): ")))
 (if newnum (setq *motnum* newnum))
 (while (setq ent (car (entsel "\nSelect next lateral: ")))
   (setq entlist (entget ent))
   (if (and (eq (cdr (assoc 0 entlist)) "INSERT")
   (= (cdr (assoc 66 entlist)) 1)
   )
     (progn
(setq next (entget (entnext ent)))
(setq newnext (subst (cons 1 (strcat *numpre* (itoa *motnum*))) (assoc 1 next) next))
(entmod newnext)
(entupd (cdr (assoc -1 newnext)))
(setq *motnum* (1+ *motnum*))
)
     )
   )
 (princ)
 )



and here's the result i get:



Command: attpref
Motor prefix (A): 1
Error: bad argument type: fixnump: nilundo Current settings: Auto = Off,
Control = All, Combine = No
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: end

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: adding a prefix to many existing attributes
« Reply #4 on: October 10, 2005, 10:57:48 AM »
I screwed that up, so I rewrote it, and posted it here
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: adding a prefix to many existing attributes
« Reply #5 on: October 10, 2005, 10:59:27 AM »
you will need to edit the block name, and the tag name, and what floor you are on.  vbaman, load the dvb,   Alt-F8 to choose the macro
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ELOQUINTET

  • Guest
Re: adding a prefix to many existing attributes
« Reply #6 on: October 10, 2005, 11:29:31 AM »
not sure which are the block and tag names in your code  :oops:

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: adding a prefix to many existing attributes
« Reply #7 on: October 10, 2005, 11:31:54 AM »
edit here

Code: [Select]
    Set objSelSet = objSelCol.Add("Motor")
    intType(0) = 0: varData(0) = "INSERT"
    intType(1) = 2: varData(1) = "MOTOR" ' <------Block Name edit here
....
    For Each objBlkRef In objSelSet
        '        If objElem.EntityName = "AcDbBlockReference" Then
        If objBlkRef.HasAttributes Then
            varArray1 = objBlkRef.GetAttributes
            For intCount = LBound(varArray1) To UBound(varArray1)
                Select Case varArray1(intCount).TagString
                    Case "000"   '<------ Tag name edit here
.....

    strNewAttribute = "2." & strOldAttribute  '<------ what floor are you on


    TagStringEdit "MOTOR", "000", , strNewAttribute    '<------edit blockname and tag here

End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: adding a prefix to many existing attributes
« Reply #8 on: October 10, 2005, 11:34:21 AM »
If you are still having problems, post your block, and I'll update the code for you.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Murphy

  • Guest
Re: adding a prefix to many existing attributes
« Reply #9 on: October 10, 2005, 12:32:41 PM »
Why not just prompt for the floor number?

Code: [Select]
Dim flr As String
flr = InputBox("What floor are we working on?", "Floor Number", "1")
strNewAttribute = flr & "." & strOldAttribute

Bob Wahr

  • Guest
Re: adding a prefix to many existing attributes
« Reply #10 on: October 10, 2005, 12:37:30 PM »
why not just
Command: -ATTEDIT
Edit attributes one at a time? [Yes/No] <Y>: N
Performing global editing of attribute values.
Edit only attributes visible on screen? [Yes/No] <Y>: N
Drawing must be regenerated afterwards.
Enter block name specification <*>: specify blk name if you need to

Enter attribute tag specification <*>: specify attrib name if you need to

Enter attribute value specification <*>:

170 attributes selected.
Enter string to change:
Enter new string: 2.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: adding a prefix to many existing attributes
« Reply #11 on: October 10, 2005, 12:54:10 PM »
would that append the 2. to the motor number?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: adding a prefix to many existing attributes
« Reply #12 on: October 10, 2005, 01:26:35 PM »
It would place 2. before the existing attribute which is what he's going after.

ELOQUINTET

  • Guest
Re: adding a prefix to many existing attributes
« Reply #13 on: October 10, 2005, 04:10:52 PM »
HEY GUYS SORRY HAVEN'T BEEN KEEPING UP WITH THE CONVERSATION. damn caps lock. anyway i found my own solution. i had a lisp which accomplished what i wanted to do after all. i'll post it when i get a moment under the gun now

hudster

  • Gator
  • Posts: 2848
Re: adding a prefix to many existing attributes
« Reply #14 on: October 11, 2005, 03:50:38 AM »
You could do this easily using the find command, under options though, make sure you only select the attributes option.

Sometime there are easier ways  :-)
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue