hi, l can't chenge a coordinate in autolisp.
(10 2500.0 1900.20 0.0)
l want subst this coordinate for (10 3000.0 2000.0 0.0)
how can l do this?
tks
Solved! Go to Solution.
Solved by john.uhden. Go to Solution.
Solved by john.uhden. Go to Solution.
@Anonymous wrote:
hi, l can't chenge a coordinate in autolisp.
(10 2500.0 1900.20 0.0)
l want subst this coordinate for (10 3000.0 2000.0 0.0)
how can l do this?
tks
Substitute the new value to a point list? or entity definition data ( product of entget )?
(setq yourlist (subst '(10 3000.0 2000.0 0.0) '(10 2500.0 1900.20 0.0) yourlist))
entity data
(setq ent (entmod (subst '(10 3000.0 2000.0 0.0) (assoc 10 ent) ent)))
HTH
Um, I think he wanted it substituted the other way, but the lesson is GOOD! (as usual)
John F. Uhden
Patrick:
It looks like Ricardo got a little confused. He accepted my answer when it should have been yours. I owe you one. We'll have some fun.
John F. Uhden
@john.uhden wrote:
Patrick:
It looks like Ricardo got a little confused. He accepted my answer when it should have been yours. I owe you one. We'll have some fun.
No worries John, a solution accepted is a victory in itself for us here regardless who gets the honour. (or should we say horror)
You did point out the inaccuracy of my post.
One of these days I'm going to collect
Cheers
The only error in your post, other than reversing the existing and desired points, was to (setq ent (entmod...)) which presumes he needs the new entity data for something else. IMHO, just entmod should have sufficed. Then again (setq ent could be a test to see if the entmod was successful. But of course one could just (if (entmod...) blah boohoo). Or better (and (entmod...) blah blaha blahaha blahahaha).
John F. Uhden
look.
( setq a ( entget ( car (nentsel) ) ) )
((-1 . <Entity name: 232c82e6cc0>) (0 . "MTEXT") (330 . <Entity name: 232c82e69f0>) (5 . "5074") (100 . "AcDbEntity") (67 . 0) (8 . "cota") (62 . 3) (440 . 16777216) (100 . "AcDbMText") (10 2884.37 3196.23 0.0) (40 . 25.0) (41 . 0.0) (46 . 0.0) (71 . 5) (72 . 1) (1 . "\\A1;37") (7 . "ROMANS") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0) (42 . 40.4762) (43 . 25.0) (50 . 0.0) (73 . 1) (44 . 1.0))
( setq b ( assoc 10 a) )
(10 2884.37 3196.23 0.0)
so, l want to subst (10 2884.37 3196.23 0.0) for ( 10 3000.0 5000.0 0.0 )
( setq a (entmod ( subst ( cons ( list 10 3000.0 5000.0 0.0 ) ) ( assoc 10 a) a)))) but l cant.
did you understand me???? hehe
Ricardo, seriously, we have to get the order of things straight. When you say "substitute A for B" it means to many of us that you would rather have A than B, as in "Can I substitute peas for green beans, please?" which means you would prefer to have the peas over the green beans.
That's the way the (subst) function works as well... (subst (cons 1 "peas")(assoc 1 dinner) dinner)).
Your two statements are opposing...
1. so, l want to subst (10 2884.37 3196.23 0.0) for ( 10 3000.0 5000.0 0.0 )
2. ( setq a (entmod ( subst ( cons ( list 10 3000.0 5000.0 0.0 ) ) ( assoc 10 a) a)))) but l cant.
Since you already have 10 in the list, I think you really want to:
(entmod ( subst ( list 10 3000.0 5000.0 0.0 ) ( assoc 10 a) a))
which is the same as...
(entmod ( subst ( cons 10 (list 3000.0 5000.0 0.0 )) ( assoc 10 a) a)), because
consing an element to a list simply adds it to the front of the list, whereas
consing one element to another returns a dotted pair, as in (cons 1 "X") returns '(1 . "X")
I sure hope that helps, otherwise I'm feeling really stupid for misunderstanding.
John F. Uhden
ricardo.projetando wrote:
( setq a (entmod ( subst ( cons ( list 10 3000.0 5000.0 0.0 ) ) ( assoc 10 a) a)))) but l cant.
-- Ricardo, it should be your first post. -- I concur
@Anonymous
if you had posted that, we could've pointed out what was wrong with the syntax on the second post. [ regardless on my mix up of to and for ]
John already explained why anyway.
All will give you the same result. except for the way you constructed your list.
DYNAMIC Different sources [ from variables ] (setq x 3238.92 y 1301.13 z 0.0 a (assoc 10 entgetdata) b (cdr (assoc 10 entgetdata))) ( list 10 x y z ) (10 3238.92 1301.13 0.0)
(cons 10 b) (10 3238.92 1301.13 0.0)
a (10 3238.92 1301.13 0.0) STATIC [ Hard coded ] '(10 3238.92 1301.13 0.0)
...
it all depends on the source and usage. Hence my question on post#2