Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ATTRIBUTE VALUE EDITING

32 REPLIES 32
SOLVED
Reply
Message 1 of 33
Kyle.para
1310 Views, 32 Replies

ATTRIBUTE VALUE EDITING

Hi

 

I have ton of blocks that I am adding attributes to, so that I can extract the data from the block.

 

I have a lisp routine to that creates the attributes I need. 

 

My goal was to fill out the attribute value inside of the block directly on the tag so that the data was always stuck inside of the block.

 

The problem is when I fill out the data inside the values on the outside of the block do not get updated.

 

I have tried to attsync, but that doesn't write the data entered into the value on the outside of the block.

 

Is there another way to do this?

 

Thanks,

32 REPLIES 32
Message 2 of 33
Kyle.para
in reply to: Kyle.para

So I now realize I need to redefine the block.  The easiest way to do this is to just reinsert the block again.

 

That way the value that I have added will show up on the newly inserted block.

 

The problem I have is that I have hundreds of blocks and this will take forever.

 

Is there a way to mass insert all the blocks again somehow?

 

We usually don't insert blocks, we just copy them out of the drawing and paste them into the drawing we're working on.

Message 3 of 33
john.vellek
in reply to: Kyle.para

Hi @Kyle.para,

 

Perhaps you can extract a list of all the block names using DataExtraction. Then, write a simple script to substitute the new block for the old one.  Can you share some files ona  post and I can take a closer look for you?

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
Message 4 of 33
hencoop
in reply to: Kyle.para

This works for me.  It asks you to select the blocks (INSERTs of the blocks actually) to update.  It runs another function (UBLK ...) which I have used for some time and which contains extra code that does things I need which I expect will not be involved in your use of it. UBLK is included below.

 

;;;
;;; Author: Henry C. Francis
;;; 425 N. Ashe St.
;;; Southern Pines, NC 28387
;;;
;;; http://www.paracadd.com
;;; All rights reserved.
;;;
;;; Edited: 3/22/2017
;;;
;;;****************************************************************************
(DEFUN C:REINSBLKS ( / blk-ss blk-cnt blk-ename from_reinsblks blk-name) (SETQ from_reinsblks NIL) (SETQ blk-ss (SSGET '((0 . "INSERT"))) blk-cnt 0 ) (WHILE (< blk-cnt (SSLENGTH blk-ss)) (SETQ blk-ename (SSNAME blk-ss blk-cnt)) (IF blk-ename (PROGN (SETQ from_reinsblks T) (SETQ blk-name (CDR (ASSOC 2 (ENTGET blk-ename)))) (UBLK blk-name) (PRINC (STRCAT "\nBlock \"" blk-name "\" updated! ")) (PRINC) (SETQ from_reinsblks NIL) ) ) (SETQ blk-cnt (1+ blk-cnt)) ) (PRINC) )

 

(DEFUN UBLK (blknm   /       lupr    attrq   ent     tsln    cntr
             inxyz   clayr   getit   natlst  taglst  inscl   inang
             bins    attr    dblnk   att1    att2    att3    tset
             tent    bent    xatlst
            )
  (setq lupr (getvar "luprec"))
  (setq attrq (getvar "attreq"))
  (setvar "ATTREQ" 0)
  (setq clayr (getvar "clayer")
        tset  (ssget "X"
                     (list (cons 0 "INSERT")
                           (cons 2 blknm)
                     ) ;_ end of list
              ) ;_ end of ssget
  ) ;_ end of setq
  (setq cntr 0)
  (COMMAND ".insert" (strcat blknm "="))
  (COMMAND nil nil nil)
  (setq bent (entget (ssname tset cntr)))
  (setq edtw (entget (cdar bent)))
  (IF (EQ (STRCASE blknm) "NEWDWGSTAMP")
    (PROGN
      (setq inxyz "1.93,0.57")
      (setq xscl 0.9)
      (setq yscl 0.9)
      (setq zscl 0.9)
    ) ;_ end of PROGN
    (PROGN
      (setq inxyz (strcat
                    (rtos (cadr (assoc 10 edtw)))
                    ","
                    (rtos (caddr (assoc 10 edtw)))
                  ) ;_ end of strcat
      ) ;_ end of setq
      (setq xscl (cdr (assoc 41 edtw)))
      (setq yscl (cdr (assoc 42 edtw)))
      (setq zscl (cdr (assoc 43 edtw)))
    ) ;_ end of PROGN
  ) ;_ end of IF
  (while (AND bent (/= (cdr (assoc 0 bent)) "SEQEND"))
    (if (= (cdr (assoc 0 bent)) "ATTRIB")
      (PROGN
        (if xatlst
          (setq xatlst (append
                         xatlst
                         (list
                           (if (eq (cdr (assoc 2 bent)) "SEC/DET_REF")
                             (cons 2 "SEC_DET_REF")
                             (assoc 2 bent)
                           ) ;_ end of if
                           (assoc 1 bent)
                         ) ;_ end of list
                       ) ;_ end of append
                taglst (strcat taglst
                               " "
                               (if (eq (cdr (assoc 2 bent)) "SEC/DET_REF")
                                 "SEC_DET_REF"
                                 (cdr (assoc 2 bent))
                               ) ;_ end of if
                       ) ;_ end of strcat
          ) ;_ end of setq
          (setq xatlst (list
                         (if (eq (cdr (assoc 2 bent)) "SEC/DET_REF")
                           (cons 2 "SEC_DET_REF")
                           (assoc 2 bent)
                         ) ;_ end of if
                         (assoc 1 bent)
                       ) ;_ end of list
                taglst
                       (if (eq (cdr (assoc 2 bent)) "SEC/DET_REF")
                         "SEC_DET_REF"
                         (cdr (assoc 2 bent))
                       ) ;_ end of if
          ) ;_ end of setq
        ) ;_ end of if
        (if (eq (cdr (assoc 2 bent)) "SEC/DET_REF")
          (PRINC "\nFIXED SEC_DET_REF! ")
          (PRINC)
        ) ;_ end of if
      ) ;_ end of PROGN
    ) ;_ end of if
    (IF (AND bent (EQ (TYPE bent) 'LIST)(EQ (TYPE (CDAR bent)) 'ENAME)(ENTNEXT(CDAR bent)))
      (setq bent (entget (entnext (cdar bent))))
      (SETQ bent NIL)
    )
  ) ;_ end of while
  (setq inang (angtos (cdr (assoc 50 edtw)) (getvar "aunits") 8))
  (IF (AND (SETQ blkssent (SSGET "X" (LIST (CONS 2 blknm)))) (ASSOC 41 (ENTGET (SSNAME blkssent 0))))
    (COMMAND ".insert" blknm inxyz xscl yscl inang)
    (COMMAND ".insert" blknm inxyz xscl inang)
  )
  (entdel (cdar edtw))
  (setq bent (entget (entlast)))
  (setq natcnt 0
        natlst nil
  ) ;_ end of setq
  (while (and bent (/= (cdr (assoc 0 bent)) "SEQEND"))
    (if (= (cdr (assoc 0 bent)) "ATTRIB")
      (progn
        (if (member (assoc 2 bent) xatlst)
          (progn
            (setq edtw
                   (subst (cadr (member (assoc 2 bent) xatlst))
                          (assoc 1 bent)
                          bent
                   ) ;_ end of subst
            ) ;_ end of setq
            (entmod edtw)
          ) ;_ end of progn
        ) ;_ end of if
      ) ;_ end of progn
    ) ;_ end of if
    (if (setq nxtentname (entnext (cdar bent)))
      (setq bent (entget nxtentname))
      (setq bent nil)
    ) ;_ end of if
  ) ;_ end of while
  (entupd (entlast))
  (setvar "LUPREC" lupr)
  (setvar "ATTREQ" attrq)
  (setvar "CLAYER" clayr)
  (COMMAND "'resume")
) ;_ end of DEFUN

 

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 5 of 33
Kyle.para
in reply to: hencoop

@hencoop

 

Thanks for the help again.  I tried your code but I get two different errors depending on the block selected.

 

FIRST ERROR

 

Command: REINSBLKS

Select objects: Specify opposite corner: 1 found

Select objects:
.insert Enter block name or [?] <CONVEYOR LH>: PULSE & FLOAT SWITCHES & ANTI-COLLISION=
"PULSE & FLOAT SWITCHES & ANTI-COLLISION.dwg": Can't find file in search path:
  S:\Kyle\Symbols\ (current directory)
  C:\Users\kpara\Desktop\
  C:\Users\kpara\appdata\roaming\autodesk\autocad electrical 2017\r21.0\enu\support\
  C:\program files\autodesk\autocad 2017\support\
  C:\program files\autodesk\autocad 2017\support\en-us\
  C:\program files\autodesk\autocad 2017\fonts\
  C:\program files\autodesk\autocad 2017\help\
  C:\program files\autodesk\autocad 2017\express\
  C:\program files\autodesk\autocad 2017\support\color\
  C:\program files (x86)\autodesk\applicationplugins\autodesk appmanager.bundle\contents\resources\
  C:\program files (x86)\autodesk\applicationplugins\autodesk appmanager.bundle\contents\windows\2017\
  C:\program files (x86)\autodesk\applicationplugins\autodesk featuredapps.bundle\contents\resources\
  C:\program files (x86)\autodesk\applicationplugins\autodesk featuredapps.bundle\contents\windows\2017\win64\
  C:\program files (x86)\autodesk\applicationplugins\autodesk importskp.bundle\contents\resources\
  C:\programdata\autodesk\applicationplugins\acemobilecompanion.bundle\contents\resources\
  C:\programdata\autodesk\applicationplugins\acemobilecompanion.bundle\contents\windows\2016\
  C:\programdata\autodesk\applicationplugins\autocad2017addin.bundle\contents\win64\
  C:\programdata\autodesk\applicationplugins\autodesk acperfmon.bundle\windows\
  S:\kyle\standards\lisps\
  C:\Program Files\Autodesk\AutoCAD 2017\drv\
  C:\Program Files\Autodesk\AutoCAD 2017\
*Invalid*
; error: Function cancelled

 

SECOND ERROR

 

Command: REINSBLKS

Select objects: 1 found

Select objects:
.insert Enter block name or [?] <A$C1F54022D>: *U1405=
** Error: You may not explode blocks using the
"block name=file name" syntax.

Command:
Command:
Command:
Command: ; error: bad argument type: lselsetp nil

Message 6 of 33
hencoop
in reply to: Kyle.para

Hi kyle.para,

 

  1. You must have external blocks to reinsert.  It is looking for the block somewhere on your “Support File Search Path” and cannot find it.
  2. You cannot reinsert anonymous blocks (blocks beginning with “*U” (blocks named “A$*” are named on the fly by pasting content so they will not be external either)
AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 7 of 33
Kyle.para
in reply to: hencoop

The blocks i edited are all in the same file so do i have to recreate all
the blocks again? That's​not going to be fun. Lol
Message 8 of 33
hencoop
in reply to: Kyle.para

No, I have a routine that will Wblock all of the blocks in a drawing. I use it to make a common library of blocks for use across multiple projects. I create blocks of specific parts as I need them if I don't have one already. When the project is done I export them to my library folder.
It is called BLKXPORT

http://paracadd.com/lisp/lisp_lst.htm#blkxport

Sent from my iPhone
AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 9 of 33
Kyle.para
in reply to: hencoop

Hi Ken,

 

When I run the program it says no function definition. Dos split path.

 

I created a folder on C: drive named blkxport.

 

Thanks,

Message 10 of 33
hencoop
in reply to: Kyle.para

DOSLIB is an ARX application from Robert McNeel & Associates.  Follow their instructions for it.  It contains the missing function.

 

Once this is all done just type BLKXPORT at the command line. (Note: the lisp files should be saved to the name shown on the links; e.g. blkxport.lsp; dimaro.lsp; ukword.lsp

 

"here" should present the position of the program on the linked page as in the image captured below:

BLKXPORT.jpg

Options.jpg

 

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 11 of 33
john.vellek
in reply to: Kyle.para

HI @Kyle.para,

 

Here is a simple routine I use at times that might help to write all your blocks out.

It isn't very fancy but it works for me. Simply download and drag onto your drawing window so it will launch.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
Message 12 of 33
Kyle.para
in reply to: hencoop

I have added everything but I still get the same error.

 

I just unzipped the DOSLIB file.  Is there something else I need to do with it?


Thanks,

Message 13 of 33
hencoop
in reply to: Kyle.para

Kyle, I apologize for bouncing around wildly for a bit as I edited my previous reply.  I got a bit confused about which thread I was replying to for a moment.

Just make sure that the version of DOSLIB for your AutoCAD installation is loaded and BLKXPORT should work for you.

 

Also, in my comments in the lisp file I say this:

"There is a "standard block list" symbol name = std_blk_lst that consists of strings which are passed to (WCMATCH str) and upon a match the block in the current file is not written out. This is to enable protection of blocks you have developed as masters or standards from being overwritten by this function."

 

The list's (SETQ...)  looks like this in the code at line #75. It is NOT stacked like this in blkxport.lsp... I stacked it here so you could see it all easily.

(SETQ my_exclude_lst
'("_ClosedBlank.dwg"
"AeccTickLine.dwg"
"AeccTickCircle.dwg"
"AeccTickTriangle.dwg"
"AeccArrow.dwg"
"Shrub 2.dwg"
"Gas Valve.dwg"
"Drainage MH.dwg"
"Proposed Hyd.dwg"
"Single Pole Sign.dwg"
"Water Shutoff.dwg"
"Drill Hole.dwg"
"Station Mark.dwg"
"Sewer Manhole.dwg"
"Benchmark.dwg"
"Existing Hyd.dwg"
"Water Valve.dwg"
"Tree 6.dwg"
"Catch Basin.dwg"
"Iron Pin.dwg"
"Guy Pole.dwg"
"Test Pit.dwg"
"Utility Pole.dwg"
"_CrowsFoot-Start.dwg"
"_CrowsFoot-End.dwg"
"_Wipeout_Circle.dwg"
"Marker Pnt.dwg"
"_ClosedFilled.dwg"
"AeccSectionMark.dwg"
"AeccSectionPntr.dwg"
"Storm Manhole.dwg"
"Flared End Section - Plan.dwg"
"Flared End Section - Profile.dwg"
"SuperLeftUpEmpty.dwg"
"SuperLeftDownEmpty.dwg"
"SuperRightDownEmpty.dwg"
"SuperRightUpEmpty.dwg"
"HighPoint.dwg"
"LowPoint.dwg"
"FullSuperLeftDownEmpty.dwg"
"FullSuperLeftUpEmpty.dwg"
"FullSuperRightUpEmpty.dwg"
"FullSuperRightDownEmpty.dwg"
"AeccArwClosedFilled.dwg"
"Tree-Deciduous.dwg"
"Hydrant-Elevation.dwg"
"Tree-Evergreen.dwg"
"HBCMW.dwg"
"HBPCW.dwg"
"_AEC_GRIPS_NONE.dwg"
"PRESSUREPARTERRORBLOCK.dwg"
"4b489b62-e834-4762-a085-7954ec19726a.dwg"
"4b489b62-e834-4762-a085-7954ec19726a_3.dwg"
"e2d441ea-1ff1-48e7-ba14-35cae9d44af1.dwg"
"e2d441ea-1ff1-48e7-ba14-35cae9d44af1_3.dwg"
"wv-blowoff.dwg"
"yard-hydrant.dwg"
"lbl_tic.dwg"
)
) ;_ end of SETQ

 

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 14 of 33
hencoop
in reply to: Kyle.para

The version that matches your version of AutoCAD needs to be loaded.  APPLOAD is good for this.  I think the numbering is the same; i.e. (GETVAR "ACADVER") returns a string beginning with the same version number you will need of DOSLIB.  Use the x64 unless you have a 32 bit system (not likely).

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 15 of 33
Kyle.para
in reply to: hencoop

OK I think that is the problem I didn't load it.  For some reason when I try to load the app it doesn't show up.  I changed the name to .arx but still doesn't show up.

Message 16 of 33
hencoop
in reply to: Kyle.para

You will not need to rename the DOSLIB ARX file that you need.  All else is a .lsp file.  Pick the one that has your version "...##x64.arx" AutoCAD 2017 is version 21.  For AutoCAD 2017 you should load DOSLib21x64.arx (if you have a 64bit OS)

 

DOSLIB-Appload.jpg

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 17 of 33
hencoop
in reply to: john.vellek

John,

 

I tried your routine.  It works well.  I had a little trouble getting the path right but I think that was me (I did not accept the default).  I had a few errors "Cannot WBLOCK externally dependent block." because I opted not to verify but verifying would have allowed me to avoid those.  I just did not think about xrefs when I opted not to.  As you said, it is not fancy; but, I think it is very effective.

As I wrote earlier, I specifically wrote mine to write out my new blocks to my library.  It works well for my specific needs but we'll have to see if it can serve Kyle's (or any else's) purposes.  Thanks for sharing your routine.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 18 of 33
Kyle.para
in reply to: hencoop

Well after all that it still didn't rewrite the new attribute data.  I tried John's program which works similar. 

 

One strange thing is it doesn't copy all of the blocks for some reason? 

 

I think I have no choice but to just copy everything inside of the block and paste it as a new block and then rename it with the old name in a different file.  Unless there is something I am missing.

Message 19 of 33
hencoop
in reply to: Kyle.para

Kyle,

 

You may already know all of this but I'll go through it all in case we've missed something.

 

Writing out your new block definitions is just part of the process.  You will need to reinsert them using an equals sign at the end of each name so that they are redefined.  If you don't do that then they will use the old definition.  I have specific code to update existing values of attributes in my new blocks but it is not applicable to just any block that has attributes.  You should be able to replace the existing instances with new definitions using the RBLK command but I don't think they will keep their existing attribute values.  They should have all of the attributes that are in your new block definitions but they will have the default values.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
Message 20 of 33
Kyle.para
in reply to: hencoop

OK Hen I spoke to soon.  You're AWESOME my man.  I just had to click defined not used and it worked.

 

I tried to enter the RBLK command but it doesn't show up.  I am using 2017 electrical.  Is there anything else I can do rather than purge and reinsert?

 

I appreciate your help so much my friend!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost