Jump to content

Recommended Posts

Posted

Hi guys,

i want to replace this

 

(setq dr1 (atof d1))

(setq dr2 (atof d2))

(setq dr3 (atof d3))

(setq dr4 (atof d4)).........

...........................................

 

with this:

 

 

 

(setq i 1)

(repeat nrpct

(set

(read (strcat "dr" (itoa i)))

(atof (read (strcat "d" (itoa i))))

 

)

(setq i (1+ i))

)

 

 

but is not working. Why? Any help? Thanks!

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • flopo

    10

  • pBe

    10

  • Lee Mac

    1

  • ketxu

    1

Top Posters In This Topic

Posted Images

Posted

assuming d1-d4 is a string

 

(atof (eval (read (strcat "d" (itoa i)))))

Posted

and this one

 

 

(setq pnr2(polar pnr1 (dtr 0) dr1))

(setq pnr3(polar pnr2 (dtr 0) dr2))

(setq pnr4(polar pnr3 (dtr 0) dr3))

 

 

to replace with this:

 

(setq i 2)

(repeat (- nrpct 1)

(set

(read (strcat "pnr" (itoa i)))

(polar (eval(read (strcat "pnr" (itoa (- i 1))))) (dtr 0) (atof( read(strcat "dr" (itoa (- i 1))))))

 

 

(setq i (1+ i))

)

)

 

 

:(

Posted
(setq i 2)
(repeat (- nrpct 1)
 (set
   (read (strcat "pnr" (itoa i)))
   (polar (eval (read (strcat "pnr" (itoa (- i 1)))))
   (dtr 0)
   (atof [color=blue][b](eval[/b][/color] (read (strcat "dr" (itoa (- i 1)))))[b][color=blue])[/color][/b]
   )
 )
 (setq i (1+ i))
)
)

Posted

Extra right parent on input-message. Something wrong...

Posted

I tried without last right paren and it doesn't work...

Posted
I tried without last right paren and it doesn't work...

 

Certainly not from the code, if:

 

(setq pnr1 '(-3.65852 4.79514 0.0));

(setq dr1 "22" );

(setq i 2)

 

(repeat (- nrpct 1)
 (set
   (read (strcat "pnr" (itoa i)))
   (polar (eval (read (strcat "pnr" (itoa (- i 1)))))
   0
   (atof (eval (read (strcat "dr" (itoa (- i 1))))))
   )
 )
 (setq i (1+ i))
)

 

I guess it wouldnt hurt to post your code here flopo, that way anyone here can participate and pinpoint the problem for you :)

Posted

I can post my code here, no problem, but i think everybody will laugh about my code... is biiiig and looks like the hell!!! So, i want to show it for everybody....but it really looks like the hell! If you want, i will show you on private message - because you help me... :)

It doesn't work and i have no ideea why...

Posted (edited)
I can post my code here, no problem, but i think everybody will laugh about my code... is biiiig and looks like the hell!!! So, i want to show it for everybody....but it really looks like the hell! If you want, i will show you on private message - because you help me... :)

It doesn't work and i have no ideea why...

 

Go ahead flopo and post it. the more heads to the better. and dont worry about how your code looks now. its part of the learning process , how do you think we started? so go ahead, post the code ;)

 

BTW: if the value of dr1-dr5.... is a real number and not a string , remove atof

 

(set
   (read (strcat "pnr" (itoa i)))
   (polar (eval (read (strcat "pnr" (itoa (- i 1)))))
   0
   (eval (read (strcat "dr" (itoa (- i 1)))))
   )
 )

 

Also tried to answer your PM but apparently you have exceeded message quota. :)

Edited by pBe
Posted

I agree with you guys, you gave me good advice. But, because my lisp knowledges are very low, instead of using this:

 

(setq i 1)

(repeat nrpct

(set

(read (strcat "dc" (itoa i)))

(rtos

(-

(car

(eval

(read

(strcat "p" (itoa i))

)

)

)

(car p1)

)

2

2

)

)

(setq i (1+ i))

)

 

 

 

 

i used

 

 

 

 

 

(if ( >= nrpct 7)

(setq dc7 (rtos(- (car p7) (car p1)) 2 2)))

(if ( >= nrpct 8)

(setq dc8 (rtos(- (car p8) (car p1)) 2 2)))

(if ( >= nrpct 9)

(setq dc9 (rtos(- (car p9) (car p1)) 2 2)))

(if ( >= nrpct 10)

(setq dc10 (rtos(- (car p10) (car p1)) 2 2)))

(if ( >= nrpct 11)

(setq dc11 (rtos(- (car p11) (car p1)) 2 2)))

(if ( >= nrpct 12)

(setq dc12 (rtos(- (car p12) (car p1)) 2 2)))

(if ( >= nrpct 13)

(setq dc13 (rtos(- (car p13) (car p1)) 2 2)))

(if ( >= nrpct 14)

(setq dc14 (rtos(- (car p14) (car p1)) 2 2)))

(if ( >= nrpct 15)

(setq dc15 (rtos(- (car p15) (car p1)) 2 2)))

(if ( >= nrpct 16)

(setq dc16 (rtos(- (car p16) (car p1)) 2 2)))

(if ( >= nrpct 17)

(setq dc17 (rtos(- (car p17) (car p1)) 2 2)))

(if ( >= nrpct 18)

(setq dc18 (rtos(- (car p18) (car p1)) 2 2)))

(if ( >= nrpct 19)

......................................

.......................................

 

till

 

(if ( >= nrpct 19)

(setq dc100 (rtos(- (car p99) (car p1)) 2 2)))

 

 

And i used this "set" of if ....in about 15 cases...

Now i'm trying to replace them, to make my lisp shorter. I would like to use LIST instead, but i don't know how...so i use what pbe show me, because is a little easier for me to understand how is working. I don't have too much time to learn more lips...so....step by step... But i will show you my masterpiece of lisp to have a good laugh!!!!

traversare-100.LSP

traversare.dwg

Posted

Nice of you to post your code flopo. i'll have a look later, looks easy enough. but first

give us an outline what those numbers represent and the block ("TAL") below them.

 

and for your benefit we'll probably give you hints and try as much as possible not to re-write your code.

 

and have a Look/See same same but different :)

Posted

About number in tabel:

first row - .....is clear

second row - distance on x axis between 2 vertices

third row - distance on x axis between first vertice and a corresponding vertice

last row - y value of each vertice - in this case my lisp is asking me to select a vertice and to tell which is the real value on Y on that point - is about a terrain profile, where in fact y is the altitude of the point - and in my lisp i show a point- a vertice on the polyline and indicate the value of altitude for that point, no matter which one.

 

That block "tal" indicate direction for terrain - the slope, which direction is - left or right. Sorry for my english!

Posted

Did you look at the link i posted? you can use the same approach. populate a pont list, see how the location of the first and 2nd point for linear dimensions were detemined using each of the polylines point vertex? i was able to all that using just two point variables.

 

You can apply that approach on your routine. try it, holler if you have any questions ;)

Posted

Ok pBe, i will try this one too, but i don't know when. My big and stupid lisp is working, and for now i use it as it is. I asked you those questions about shortening my lisp with ...... (setq i 1) (repeat nrpct (set(read (strcat "dc" (itoa i))) ...... because i was trying to learn something more.... but what you show me in this last lisp is far too much for my level... thanks for your advice!

Posted
Ok pBe, i will try this one too, but i don't know when. My big and stupid lisp is working, and for now i use it as it is. I asked you those questions about shortening my lisp with ...... (setq i 1) (repeat nrpct (set(read (strcat "dc" (itoa i))) ...... because i was trying to learn something more.... but what you show me in this last lisp is far too much for my level... thanks for your advice!

 

Tell you what flopo. we will still use your approach, i'm only giving you options for you to think about. I'll make my suggestions based on how your routine is wriiten now and how can we make it shorter. be patient flopo. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...