Entmod/entupd question

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?
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Hi Michael
I'm not sure, but nobody replied yet....
In snipped-for-privacy@news1.newsguy.com snipped-for-privacy@dont.try (Michael Bulatovich) wrote to all:

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
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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>
<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?
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Yeah, the entupd was a "Hail Mary". It didn't work without it, so I tried adding it. I also tried a regen.
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Maybe I should try animal sacrifice, or a little dance...?

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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 ?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Sorry wrong word --- it's quite smart to find the front of the list with Reverse and _then Member .
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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.
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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.
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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...
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
LtsMatch.LSP now on the website if anyone's interested.
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Michael Bulatovich wrote:

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 ;))
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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 )

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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
Michael Bulatovich wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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.
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.