Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How change coordinates in autolisp

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
2280 Views, 9 Replies

How change coordinates in autolisp

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

9 REPLIES 9
Message 2 of 10
pbejse
in reply to: Anonymous


@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

 

Message 3 of 10
john.uhden
in reply to: pbejse

Um, I think he wanted it substituted the other way, but the lesson is GOOD! (as usual)

John F. Uhden

Message 4 of 10
john.uhden
in reply to: pbejse

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

Message 5 of 10
pbejse
in reply to: john.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) Smiley LOL

You did point out the inaccuracy of my post.

 

One of these days I'm going to collect Smiley Happy

 

Cheers

 

 

Message 6 of 10
john.uhden
in reply to: pbejse

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

Message 7 of 10
Anonymous
in reply to: john.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

 

 

Message 8 of 10
devitg
in reply to: Anonymous

Ricardo, it should be your first post. 

Message 9 of 10
john.uhden
in reply to: Anonymous

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

Message 10 of 10
pbejse
in reply to: Anonymous


ricardo.projetando wrote: 

 

( setq a (entmod ( subst ( cons  ( list 10 3000.0 5000.0 0.0 ) ) ( assoc 10 a) a)))) but l cant.


@devitg 

 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report