Author Topic: Attribute values not showing  (Read 2931 times)

0 Members and 1 Guest are viewing this topic.

WPerciful

  • Guest
Attribute values not showing
« on: March 18, 2014, 08:47:27 AM »
I used entmod and entupd to modify the attribute values in our titleblock.  It modifyed the values but you can't see them in the block.  If you double click on the block to edit the values they are all there.

Why does it have the values but not show them?

Tharwat

  • Swamp Rat
  • Posts: 712
  • Hypersensitive
Re: Attribute values not showing
« Reply #1 on: March 18, 2014, 09:18:17 AM »
Can you post your codes or just the part that is related to attributed values ?

WPerciful

  • Guest
Re: Attribute values not showing
« Reply #2 on: March 18, 2014, 09:50:09 AM »



Code: [Select]
(defun updateborder ( ent passed / e d o n )
(setq e  ent
d (entget e)
o (assoc 1 d)
n (cons 1 passed)
d  (subst n o d)
)
(entmod d)
(entupd e)
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Attribute values not showing
« Reply #3 on: March 18, 2014, 10:14:04 AM »
Just a guess
Is the ent the border insert or the attribute

add something like
(print (cdr (assoc 0 ent)))
to that code block.

and add
(redraw ent 4)
after the entupd


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Tharwat

  • Swamp Rat
  • Posts: 712
  • Hypersensitive
Re: Attribute values not showing
« Reply #4 on: March 18, 2014, 11:30:23 AM »
Try this simple code and let me know if this works.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ s n e)
  2.   (princ "\n Select Attributed block :")
  3.   (if (setq s (ssget "_+.:S:E" '((0 . "INSERT") (66 . 1))))
  4.     (progn
  5.       (setq n (ssname s 0))
  6.       (while (and (setq n (entnext n))
  7.                   (/= (cdr (assoc 0 (setq e (entget n)))) "SEQEND")
  8.              )
  9.         (if (eq (cdr (assoc 0 e)) "ATTRIB")
  10.           (entmod (subst '(1 . "Example") (assoc 1 e) e))
  11.         )
  12.       )
  13.     )
  14.   )
  15.   (princ)
  16. )
  17.  
s .


Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Attribute values not showing
« Reply #5 on: March 18, 2014, 01:21:21 PM »
Try:
Code: [Select]
(defun updateborder ( ent str / enx )
    (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget ent)))))
        (if (entmod (subst (cons 1 str) (assoc 1 (reverse enx)) enx))
            (entupd ent)
            (prompt "\nModification failed.")
        )
        (prompt "\nObject is not an Attribute Reference.")
    )
)

WPerciful

  • Guest
Re: Attribute values not showing
« Reply #6 on: March 18, 2014, 02:39:17 PM »
Thank you everyone.

I don't know why but I'm getting this error:

Code: [Select]
<Bad Entity name: FFB27180>

Tharwat

  • Swamp Rat
  • Posts: 712
  • Hypersensitive
Re: Attribute values not showing
« Reply #7 on: March 18, 2014, 02:46:09 PM »

I don't know why but I'm getting this error:

Code: [Select]
<Bad Entity name: FFB27180>

Can you upload a sample drawing ?

WPerciful

  • Guest
Re: Attribute values not showing
« Reply #8 on: March 18, 2014, 03:25:36 PM »
I have hundreds of drawings like the GF-9303-R100.dwg.  They were created using the wrong border. 

I have  a routine that to get the attribute values, delete the border, and insert the new one and I was going to use a script to process them.  But I get the bad entity error.

Thank you for all of your help!

WPerciful

  • Guest
Re: Attribute values not showing
« Reply #9 on: March 18, 2014, 03:40:10 PM »
I don't know what but the ename's don't match.



Code: [Select]
(setq sse (ssname (ssget "x" '((0 . "INSERT")(2 . "STERLING_TB"))) 0)
e (car (entsel))
)

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Attribute values not showing
« Reply #10 on: March 18, 2014, 03:40:38 PM »
I have  a routine that to get the attribute values, delete the border, and insert the new one and I was going to use a script to process them.

If the attribute tags are the same, you can import the definition of the updated block into the drawing and simply change the name of the old block reference to that of the new block definition (that is, if it is different - if its the same, the old block definition will be redefined and the block reference will already use the new definition).

ATTSYNC will then sort out the attribute positions whilst retaining the original values (providing the tags are the same, as noted).

WPerciful

  • Guest
Re: Attribute values not showing
« Reply #11 on: March 18, 2014, 03:56:12 PM »
Inside the titleblock is our logo block (TSI_LOGO_OLD).  I only need to replace that bock from within the titleblock by a function so that I can batch process them.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Attribute values not showing
« Reply #12 on: March 18, 2014, 04:10:16 PM »
Inside the titleblock is our logo block (TSI_LOGO_OLD).  I only need to replace that bock from within the titleblock by a function so that I can batch process them.

Try this hastily written code:
Code: [Select]
(defun replacelogoblock ( / doc dwg new old par )
    (setq par "STERLING_TB"  ;; parent block
          old "TSI_LOGO_OLD" ;; old block name
          new "TSI_LOGO_NEW" ;; new block name
    )
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (cond
        (   (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (getvar 'clayer))))))
            (princ "\nCurrent layer locked.")
        )
        (   (not (tblsearch "block" old))
            (princ (strcat "\n" old " not present in drawing."))
        )
        (   (not (tblsearch "block" par))
            (princ (strcat "\n" par " not present in drawing."))
        )
        (   (not (or (tblsearch "block" new)
                     (and (setq dwg (findfile (strcat new ".dwg")))
                          (progn
                              (vla-delete
                                  (vla-insertblock
                                      (vla-get-modelspace doc)
                                      (vlax-3D-point 0 0)
                                      dwg 1.0 1.0 1.0 0.0
                                  )
                              )
                              (tblsearch "block" new)
                          )
                      )
                 )
             )
             (princ (strcat "\n" new ".dwg not found."))
        )
        (    t
             (vlax-for obj (vla-item (vla-get-blocks doc) par)
                 (if
                     (and
                         (= "AcDbBlockReference" (vla-get-objectname obj))
                         (=  (strcase old)
                             (if (vlax-property-available-p obj 'effectivename)
                                 (strcase (vla-get-effectivename obj))
                                 (strcase (vla-get-name obj))
                             )
                         )
                         (vlax-write-enabled-p obj)
                     )
                     (vla-put-name obj new)
                 )
             )
             (vla-regen doc acallviewports)
        )
    )
    (princ)
)
(vl-load-com) (princ)

Change block names as required.

WPerciful

  • Guest
Re: Attribute values not showing
« Reply #13 on: March 18, 2014, 04:32:02 PM »
 :-)

That did it!

Thank you!!

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Attribute values not showing
« Reply #14 on: March 18, 2014, 05:52:13 PM »
You're welcome!  :-)