Entmod/entupd question

Discussion in 'AutoCAD' started by Herbert Koenig, Aug 19, 2006.

  1. Hi Michael

    I'm not sure, but nobody replied yet....

    In
    here you setq ent to be only what you extracted and discarded the
    rest. Sometimes it is allowed to give ACAD an incomplete list of an
    entity for entupd and let ACAD do the rest. In your case I don't see
    how even the entity-name is preserved, so how should acad be able to
    deal with it in entmod?

    I never relied on ACAD completing my work, so I always subst in the
    complete list returned by entget before entmod and entupd.


    OTOH I never dealt with group code 48 and don't have an ACAD handy, so
    maybe I'm besides the point. I'm off for a week.

    Cheers,

    Herbert
     
    Herbert Koenig, Aug 19, 2006
    #1
  2. I'm writing a routine where I want to pull one item out of the entdata of an
    object. Here's the pertinent section of code:

    (while (>= counter 0)
    (setq item (ssname ss counter))
    (setq ent (entget item))
    (setq backhalf(cdr(member (assoc 48 ent) ent)))
    (setq fronthalf(reverse(cdr(member(assoc 48 (reverse ent))(reverse
    ent)))))
    (setq ent (append fronthalf backhalf))
    (entmod ent)(entupd item)
    (setq counter (1- counter))
    )

    When I test ent before and after the entmod, it looks right. When I test the
    entdata of item before and after the entupd, it is the same(unchanged).

    The routine exits as if done, but the object on screen is unchanged, and
    when I use (entget(car(entsel))) at the command prompt and pick the object,
    the list is unchanged.

    What am I doing wrong?
     
    Michael Bulatovich, Aug 19, 2006
    #2
  3. Herbert Koenig

    Carl AK Guest

    Some ideas....


    If the code is not modifying a subentity such as an attribute, there
    should not be a need for 'entupd'. Does it work without that? If an
    entity with nested items, a 'regen' may be needed.
     
    Carl AK, Aug 19, 2006
    #3
  4. Herbert Koenig

    per.corell Guest

    Every other line but this make sense ;

    (setq fronthalf(reverse(cdr(member(assoc 48 (reverse ent))(reverse
    ent)))))

    It is quite smart to reverse the list and find the front with Reverse
    --- but didn't you use Cdr once to much , --- in the fronthalf ?
     
    per.corell, Aug 19, 2006
    #4
  5. Herbert Koenig

    per.corell Guest

    Sorry wrong word --- it's quite smart to find the front of the list
    with Reverse and _then Member .
     
    per.corell, Aug 19, 2006
    #5
  6. Hi Herbert,


    As I said before, when I check ent before and after the entmod call it look
    *right*, but when I check the entdata of the object before and after the
    entmod, it remains the same.

    <snip>

    The point of this code *is* to remove (assoc 48) which is LTSCALE override
    for the item, and return its LTSCALE to the default, which is no (assoc 48).
    The enitity should survive this 'pruning' because the presence of this item
    is optional.
    The entity name is preserved as the first member in "fronthalf".
    Can you use subst with null?
     
    Michael Bulatovich, Aug 19, 2006
    #6
  7. Herbert Koenig

    Jiro Guest

    HiHo;
    I don't know where Herbert got the group code 48 but if that
    is the entity my bible says Re: "entmod","you cannot use any linetype......
    not already defined in the current drawing session".
    Found on page 13-22 in "Autolisp Programming".
    Would the "subst" function work?
     
    Jiro, Aug 19, 2006
    #7
  8. Yeah, the entupd was a "Hail Mary". It didn't work without it, so I tried
    adding it. I also tried a regen.
     
    Michael Bulatovich, Aug 19, 2006
    #8
  9. It seems to work, when I monitor the value of fronthalf, and then the new
    appended ent. Where it seems to fail is at the entmod.
     
    Michael Bulatovich, Aug 19, 2006
    #9
  10. Thanks, I made that up myself. I am astounded at the lack of facility in
    handling lists in LISP before all those nifty vl-functions came along. I
    couldn't remember the usual way of deleting an item form the list except by
    using CDR , which got me halfway there until I remembered REVERSE...

    If nobody knows why this doesn't work, I'm going to try deleting the
    original, and creating a new item from what appears to be a valid list.
     
    Michael Bulatovich, Aug 19, 2006
    #10
  11. Group 48 is LTSCALE override. The absence of the group indicates no
    override: line displayed as per system variable. ( A bit like no color being
    BYLAYER.)

    As background, elsewhere in the routine, I have added a group 48 (matching
    the value extracted from another item picked by user) to the data of an
    entity that had none (giving it an override), *AND* substituted a group 48
    of a different value in an entity that had one.

    ENTMOD works fine in that section (excerpted below):

    (while (>= counter 0)
    (setq item (ssname ss counter))
    (setq ent (entget item))
    (if (assoc 48 ent)
    (progn
    (setq ent (subst lts (assoc 48 ent) ent))
    (entmod ent) ;modify the ent
    (setq counter (1- counter))
    );end then progn
    (progn
    (setq ltss(list lts))
    (setq ent (append ent ltss))
    (entmod ent) ;modify the ent
    (setq counter (1- counter))
    );end else progn
    );end if
    )
     
    Michael Bulatovich, Aug 19, 2006
    #11
  12. Maybe I should try animal sacrifice, or a little dance...?
     
    Michael Bulatovich, Aug 19, 2006
    #12
  13. Well, I tried that and it worked.

    It proves the list was fine, but that the ENTMOD was not working for some
    reason. I can live with this approach, but would like to understand ENTMOD
    better...
     
    Michael Bulatovich, Aug 19, 2006
    #13
  14. LtsMatch.LSP now on the website if anyone's interested.
     
    Michael Bulatovich, Aug 19, 2006
    #14
  15. All the code I've been doing recently uses the SUBST command. This is
    pulled out of one of the functions:

    (setq new (entget (entlast)) ; the string will
    be the last entity
    new (subst (cons 1 a) (assoc 1 new) new)
    ; set up to change
    the text in the
    ; database
    )
    (entmod new) ; update the database

    This is for the text string (in an on-screen editor), but the principal
    should work for code 48.

    Martin
     
    Martin Shoemaker, Aug 19, 2006
    #15
  16. The difference here is that I want no code 48 to remain, so the question is
    can SUBST substitute a null for a dotted pair. I haven't tried it since I
    got it to work with ENTDEL and ENTMAKE.
     
    Michael Bulatovich, Aug 19, 2006
    #16
  17. Herbert Koenig

    per.corell Guest

    I am sorry to say that I don't compleatly agrea with that --- but it is
    also becaurse the way I try to use Lisp ; for me the ideal Lisp program
    ,is one compressed line of code , that "make the answer" . What I mean
    is, that you maby added one to many "Reverse or "Cdr and overlook that.
    I find there are plenty --- and with the enginous use you display,
    splitting the entity list reversing it to remove a particular sub-list
    with "Member that's just perfect , the "old" Lisp functions seem to
    handle things in a way that would be quite boring with any other
    processing languages . ------ Just one line of code emagine how many
    lines that would take with any other language.

    ------ maby I shuld add that this also mean ,that it often are easier
    to rewrite a function compleatly instead of trying to remember why you
    coded it like that 2 years ago ;))
     
    per.corell, Aug 20, 2006
    #17
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.