TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: T.Willey on January 11, 2010, 04:47:26 PM

Title: Entmod error on Attributes in '09
Post by: T.Willey on January 11, 2010, 04:47:26 PM
I don't want this to get lost in another topic, so I'll start a new one.  This was brought to my attention by Joe B. when he was looking for help on an mtext situation, but I think it is a problem of attributes ( ref topic (http://www.theswamp.org/index.php?topic=31084.0) ).  The attribute will not show anything, even though it changes the string, and if you look at the dxf code you see it there.  Anyone know why this happens?  You can use the ActiveX properties to get it to work, but was wondering if anyone has heard anything about entmod and errors in '09?

Code: [Select]
(defun c:Test (/ data )
   
    (while t
        (entmod
            (subst
                (cons 1 "testing")
                (assoc 1 (setq data (entget (car (nentsel)))))
                data
            )
        )
    )
)
Code: [Select]
(defun c:Test2 (/ obj )
   
    (while t (vla-put-textstring (setq obj (vlax-ename->vla-object (car (nentsel)))) "testing 2"))
)
Title: Re: Entmod error on Attributes in '09
Post by: Andrea on January 11, 2010, 05:11:11 PM
strange...it work well for me..

attribute, Text, Mtext..
don't forget the "AcDbAttributeDefinition"

tested on '09 and '10
Title: Re: Entmod error on Attributes in '09
Post by: T.Willey on January 11, 2010, 05:21:00 PM
Man..... now I can't even duplicate it.  I even reopened the drawing it was erroring in, and it is working now.  When it happens again I'll see if I can see anything different.  Thanks for testing Andrea.
Title: Re: Entmod error on Attributes in '09
Post by: Joe Burke on January 12, 2010, 08:50:46 AM
Hi Tim,

An atrribute reference may contain multiple DXF 1 codes. Apparently this happens when text is pasted into an attribute.

I hope this sheds some light on your question.
Title: Re: Entmod error on Attributes in '09
Post by: Crank on January 12, 2010, 01:33:57 PM
[...]An atrribute reference may contain multiple DXF 1 codes. [...]
It's even more complicated:
If there are two groups 1, the real string is in the 2nd group. But if the text string
is greater than 250 characters, the string is divided into 250-character chunks, which appear
in one or more group 3 codes. If group 3 codes are used, the last group is a group 1 and has
fewer than 250 characters.
Title: Re: Entmod error on Attributes in '09
Post by: Joe Burke on January 13, 2010, 06:49:55 AM
I agree, but that's not hard thing to deal with.

Get all the DXF codes 1 and 3, likley using vl-remove-if-not source entget list. Then check for multiple 1 codes at the front end of the list. If found, (setq lst (cdr lst)).

Then strcat what remains.
Title: Re: Entmod error on Attributes in '09
Post by: Lee Mac on January 13, 2010, 10:30:59 AM
I agree, but that's not hard thing to deal with.

Get all the DXF codes 1 and 3, likley using vl-remove-if-not source entget list. Then check for multiple 1 codes at the front end of the list. If found, (setq lst (cdr lst)).

Then strcat what remains.

As shown in our other thread  :wink:
Title: Re: Entmod error on Attributes in '09
Post by: T.Willey on January 14, 2010, 05:35:17 PM
Well it is happening again right now.  I can't see anything that is causing it, and it only is happening in the one drawing, and not every time.  There is only one dxf code 1, so that isn't the issue.  I edit it with code, and the new string doesn't show up when using ' entmod ' once.  I even tried to ' entupd ' it, but that didn't make it show, as it is still in the drawing just not being shown.  If I did another ' entmod ' to it, then it will show up.  I'm kind of stumped, but will leave the drawing open to test other ideas.  My other code that I changed to use ActiveX calls works though.  I tried to see if it would show with a plot preview, but that didn't show the attribute info either.  Here is the dxf code, I don't think it is any help though.
Code: [Select]
(-1 . <Entity name: 7ddf6518>)
(0 . "ATTRIB")
(330 . <Entity name: 7ddf6500>)
(5 . "6373")
(100 . "AcDbEntity")
(67 . 1)
(410 . "Layout1")
(8 . "E-ARTAG-NAM")
(100 . "AcDbText")
(10 29.0567 13.8875 0.0)
(40 . 0.09375)
(1 . "STORAGE")
(50 . 0.0)
(41 . 1.0)
(51 . 0.0)
(100 . "AcDbAttribute")
(2 . "%%URNAM")
(70 . 0)
(73 . 0)
(74 . 0)
(280 . 0)

Edit:  After writing this, everything is working fine now.  :realmad: :lol:  I'm totally lost on this one.
Title: Re: Entmod error on Attributes in '09
Post by: Lee Mac on January 14, 2010, 05:55:28 PM
Tim,

I find that entupd does not work for Attribs and that a vla-regen is necessary  :wink:
Title: Re: Entmod error on Attributes in '09
Post by: gile on January 15, 2010, 02:02:44 AM
Hi

Excuse me if I misunderstand the issue.
entupd have to be called on the parent entity i.e. the block reference rather than the attribute.

Code: [Select]
(defun c:Test (/ data )
    (while t
        (entmod
            (subst
                (cons 1 "testing")
                (assoc 1 (setq data (entget (car (nentsel)))))
                data
            )
        )
      (entupd (cdr (assoc 330 data)))
    )
)
Title: Re: Entmod error on Attributes in '09
Post by: CAB on January 15, 2010, 08:47:22 AM
Good point Gile.
Title: Re: Entmod error on Attributes in '09
Post by: T.Willey on January 15, 2010, 11:04:24 AM
I'll try both options, Lee's and Gile's, when it happens again.  Thanks guys.