Jump to content

Recommended Posts

Posted (edited)

Hello everyone, need some help with lisp, can you underline the mistakes please.

 

I fixed what you told guys, but the new error came, dont know where to look. Edited the program.

 

error: bad argument type: numberp: nil

 

;Funkcija pavercianti laipsnius i radianus

(defun dtr (alfa)
 (* pi (/ alfa 180.0))
)
;Duomenų įvedimas

(defun duom ()
 (setq t0 (getpoint "\n Pažymėti pradžios tašką t0:"))
 (if (null t0) (setq t0 (list 10.0 10.0)))
 (setq h (getdist "\n Įveskite aukšti h: <30>:"))
 (if (null h) (setq h 30))
 (setq L (getdist "\n Įveskite ilgį L: <25>:"))
 (if (null L) (setq L 25))
 (setq R1 (getdist "\n Įveskite spindulį R1: <9>:"))
 (if (null R1) (setq R1 9))
 (setq R2 (getdist "\n Įveskite spindulį R2: <18>:"))
 (if (null R2) (setq R2 18))
 (setq W (getdist "\n Įveskite linijos plotį W: <0.5>:"))
 (if (null W) (setq W 0.5))
 )
;Koordinačių priskyrimas

(defun koord ()
(setq t1 (polar t0 (dtr 90) h))
(setq t2 (polar t1 (dtr 0) (- L R1)))
(setq T3 (polar t2 (dtr 270) R1))
(setq t4 (list (+ (- L R1) (- (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) (/(* (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) R2) (+ R1 R2)))) (/(* R2 (- h R1)) (+ R1 R2)))) 
(setq T6 (list (+ (car t3) (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1))))) (cadr t0))) 
(setq t5 (list (- (car T6) R2) (cadr t0)))
)
;--Braižymas
   (defun braiz ()
    (command "PLINE" t0 "w" W "" t1 t2 "ARC" "A" "-90" "CE" t3 t4 "CE" T6 t5 "L" t0 "") 
(setq pl (entlast))
     (command "hatch" "ansi31" 1 0 pl "")
   )
;Pagrindine programa
(defun C:PRZC()
 (duom)
 (koord)
 (braiz)
 (princ)
)

Edited by butelys
  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • neophoible

    12

  • butelys

    7

  • hmsilva

    3

  • dbroada

    1

Top Posters In This Topic

Posted Images

Posted

I'm not going to answer but will point out that if you had used

 tags you wouldn't get the smiley faces.
Posted

This seems to be the most offending portion. For starters, take a look below. I didn't try to check the routine. I only point out that you are missing several parentheses somewhere. This is just an example correction.

;Koordinaciu priskyrimas
(defun koord ()
[color=red]; use setq, don't write equations (except as comments)[/color]
 s1=(+ R1 R2)
 s2=(sqrt(-(* s1 s1) (* (- h R1) (- h R1))))
 s3=(/(* s2 R2) s1)
 (setq t1 (polar t0 (dtr 90) h))
 (setq t2 (polar t1 0 (- L R1)))
 (setq T3 (polar t2 (dtr 270) R))
 (setq t4 (list (+ (- L R1) (- s2 s3)) (/(* R2 (- h R1)) s1) [b][color=red]))[/color][/b]
 (setq t5 (list (- (car T6) R2) (cadr t0)) [b][color=red])[/color]
[/b]   (setq T6 (list (+ (car t3) s2) (cadr t0)) [color=red][b])[/b][/color]
)

Posted

Changed the program as you told guys, but the error changed. Any ideas?

Posted

Look at the first post, its edited.

Posted
Look at the first post, its edited.
Maybe, but you neglected to reply to the other comments.
Posted

Sorry, I'm new here. Edited everything as you asked.

Posted

Perhaps something like this

Code:
;Funkcija pavercianti laipsnius i radianus

(defun dtr (alfa)
 (* pi (/ alfa 180.0))
)
;Duomenu ivedimas

(defun duom ()
 (setq t0 (getpoint "\n Pažymeti pradžios taška t0:"))
 (if (null t0) (setq t0 (list 10.0 10.0)))
 (setq h (getdist "\n Iveskite aukšti h: <30>:"))
 (if (null h) (setq h 30))
 (setq L (getdist "\n Iveskite ilgi L: <25>:"))
 (if (null L) (setq L 25))
 (setq R1 (getdist "\n Iveskite spinduli R1: <9>:"))
 (if (null R1) (setq R1 9))
 (setq R2 (getdist "\n Iveskite spinduli R2: <18>:"))
 (if (null R2) (setq R2 18))
 (setq W (getdist "\n Iveskite linijos ploti W: <0.5>:"))
 (if (null W) (setq W 0.5))
 )
;Koordinaciu priskyrimas

(defun koord ()
(setq t1 (polar t0 (dtr 90) h))
(setq t2 (polar t1 (dtr 0) (- L R1)))
(setq T3 (polar t2 (dtr 270) R1));; R don't exists I did change it to R1 for testing...
(setq t4 (list (+ (- L R1) (- (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) (/(* (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) R2) (+ R1 R2)))) (/(* R2 (- h R1)) (+ R1 R2)))) 
;(setq t5 (list (- (car T6) R2) (cadr t0)));; T6 is not set yet
(setq T6 (list (+ (car t3) (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1))))) (cadr t0)))
(setq t5 (list (- (car T6) R2) (cadr t0)))
)
;--Braižymas
   (defun braiz ()
    (command "PLINE" t0 "w" W "" t1 t2 "ARC" "A" "-90" "CE" t3 t4 "CE" T6 t5 "L" t0 "") 
(setq pl (entlast))
     (command "hatch" "ansi31" 1 0 pl "")
   )
;Pagrindine programa
(defun C:PRZC()
 (duom)
 (koord)
 (braiz)
 (princ)
)

HTH

Henrique

Posted

Thanks hmsilva, Can anyone tell my is there something bad with this line, or the problem is in my setq points? pictures attached, what I want to get and what I get.

(command "PLINE" t0 "w" W "" t1 t2 "ARC" "A" "-90" "CE" T3 t4 "CE" T6 t5 "L" t0 "")

20140519_220909.jpg

1.png

Posted
Sorry, I'm new here. Edited everything as you asked.
That's much better. When calculating T3, what is R supposed to be?

 

(setq T3 (polar t2 (dtr 270) R))

Posted

;Koordinačių priskyrimas

It looks like T6 is being used before it is being defined here:

(defun koord ()
(setq t1 (polar t0 (dtr 90) h))
(setq t2 (polar t1 (dtr 0) (- L R1)))
[b](setq T3 (polar t2 (dtr 270) [color=red]R[/color]))[/b]
(setq t4 (list (+ (- L R1) (- (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) (/(* (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) R2) (+ R1 R2)))) (/(* R2 (- h R1)) (+ R1 R2)))) 
[b](setq t5 (list (- (car [color=red]T6[/color]) R2) (cadr t0)))[/b]
(setq [b][color=red]T6 [/color][/b](list (+ (car t3) (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1))))) (cadr t0))) 
)

Again, note that R is used for T3.

Posted

butelys, you are obviously new to this, which is OK. Note that all of your variables are being treated as globals, that is, they are all accessible outside the routines and the main program as well. This means that they may have values assigned to them already, but the program will not know what they are, unless it checks. So, it could be using an old value for a new run. In the cases I cited, R and T6 could already have values, which might or might not agree with what you are trying to do.

Posted

Made the changes, but still get it wrong as in the last post attachments. I know that I'm new, trying to understand the mistakes with your help guys. :)

Posted
Made the changes, but still get it wrong as in the last post attachments. I know that I'm new, trying to understand the mistakes with your help guys. :)
It wasn't intended as criticism, I just meant that you may not understand what I'm talking about. Whenever that's the case, just ask.
Posted

Since your variables are globals, you can easily check their values with what you expected. Have you done that?

Posted

Here's a list from my results using the defaults.

 

Command: !t0

(10.0 10.0)

 

Command: !t1

(10.0 40.0)

 

Command: !t2

(26.0 40.0)

 

Command: !t3

(26.0 31.0)

 

Command: !t4

(21.6569 14)

 

Command: !t5

(24.9706 10.0)

 

Command: !t6

(42.9706 10.0)

Posted

Also, have you tried drawing the figure manually using the expected results and your command line code?

Posted (edited)

butelys,

please note that using command cals, you must ensure that OSMODE is set to zero.

 

;Funkcija pavercianti laipsnius i radianus

(defun dtr (alfa)
 (* pi (/ alfa 180.0))
)
;Duomenu ivedimas

(defun duom ()
 (setq t0 (getpoint "\n Pažymeti pradžios taška t0:"))
 (if (null t0) (setq t0 (list 10.0 10.0)))
 (setq h (getdist "\n Iveskite aukšti h: <30>:"))
 (if (null h) (setq h 30))
 (setq L (getdist "\n Iveskite ilgi L: <25>:"))
 (if (null L) (setq L 25))
 (setq R1 (getdist "\n Iveskite spinduli R1: <9>:"))
 (if (null R1) (setq R1 9))
 (setq R2 (getdist "\n Iveskite spinduli R2: <18>:"))
 (if (null R2) (setq R2 18))
 (setq W (getdist "\n Iveskite linijos ploti W: <0.5>:"))
 (if (null W) (setq W 0.5))
 )
;Koordinaciu priskyrimas

(defun koord ()
(setq t1 (polar t0 (dtr 90) h))
(setq t2 (polar t1 (dtr 0) (- L R1)))
(setq T3 (polar t2 (dtr 270) R1));; R don't exists I dis change to R1 for testing...
;(setq t4 (list (+ (- L R1) (- (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) (/(* (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1)))) R2) (+ R1 R2)))) (/(* R2 (- h R1)) (+ R1 R2)))) 
;(setq t5 (list (- (car T6) R2) (cadr t0)));; T6 is not set yet
(setq T6 (list (+ (car t3) (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1))))) (cadr t0)))
(setq T5 (list (- (car T6) R2) (cadr t0)))
(setq T4 (polar T3 (angle T3 T6) R1))
)
;--Braižymas
   (defun braiz ()
    (command "PLINE" t0 "w" W "" t1 t2 "ARC" "A" "-90" "CE" t3 t4 "CE" T6 t5 "L" t0 "") 
(setq pl (entlast))
     (command "hatch" "ansi31" 1 0 pl "")
   )
;Pagrindine programa
(defun C:PRZC( / W H L R1 R2 T0 T1 T2 T3 T4 T5 T6 PL)
 (duom)
 (koord)
 (braiz)
 (princ)
)

EDIT:You shouldn't allow the user to set the radius, from the image you've posted, the radius should always be R1=0.3H and R2=0.6H, so the user should only enter values for height, width and line width...


;Funkcija pavercianti laipsnius i radianus

(defun dtr (alfa)
 (* pi (/ alfa 180.0))
)
;Duomenu ivedimas

(defun duom ()
 (setq t0 (getpoint "\n Pažymeti pradžios taška t0:"))
 (if (null t0) (setq t0 (list 10.0 10.0)))
 (setq h (getdist "\n Iveskite aukšti h: <30>:"))
 (if (null h) (setq h 30))
 (setq L (getdist "\n Iveskite ilgi L: <25>:"))
 (if (null L) (setq L 25))
 (setq W (getdist "\n Iveskite linijos ploti W: <0.5>:"))
 (if (null W) (setq W 0.5))
 (setq R1 (* 0.3 h))
 (setq R2 (* 0.6 h))
 )
;Koordinaciu priskyrimas

(defun koord ()
(setq t1 (polar t0 (dtr 90) h))
(setq t2 (polar t1 (dtr 0) (- L R1)))
(setq T3 (polar t2 (dtr 270) R1))
(setq T6 (list (+ (car t3) (sqrt(- (* (+ R1 R2) (+ R1 R2)) (* (- h R1) (- h R1))))) (cadr t0)))
(setq T5 (list (- (car T6) R2) (cadr t0)))
(setq T4 (polar T3 (angle T3 T6) R1))
)
;--Braižymas
   (defun braiz ()
    (command "PLINE" t0 "w" W "" t1 t2 "ARC" "A" "-90" "CE" t3 t4 "CE" T6 t5 "L" t0 "") 
(setq pl (entlast))
     (command "hatch" "ansi31" 1 0 pl "")
   )

;Pagrindine programa
(defun C:PRZC ( / W H L R R1 R2 T0 T1 T2 T3 T4 T5 T6 PL)
 (duom)
 (koord)
 (braiz)
 (princ)
)

 

hope that helps

Henrique

Edited by hmsilva
Posted
Thanks hmsilva, Can anyone tell my is there something bad with this line, or the problem is in my setq points? pictures attached, what I want to get and what I get.

(command "PLINE" t0 "w" W "" t1 t2 "ARC" "A" "-90" "CE" T3 t4 "CE" T6 t5 "L" t0 "")

I don't think you want to set the angle to -90 here, do you?

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