Jump to content

Recommended Posts

Posted (edited)

So i got a problem with autolisp, i need to make program which would draw a simple form. I wrote the program but it sais that there is a mistake somewhere and i cant find it. I'm from Lithuania so some of the text you wont understand but its not important anyway, so here is the program and i attached the file.

 

; -------------------------------------------------------
; profa.lsp
; Profilio braižymas
; DB0/3 gr. stud. G., Sveikataitė
; D. Kalisinskas
; KTU, Inžinerinės grafikos katedra.
; --DTR funkcijos įvedimas į programą-----
(defun dtr (alfa)
       (* pi (/ alfa 180.0))
   )
;Duomenų įvedimas: p0, L, L1, H, c, b, R1, W, Fi
   (defun duom ()
       (setq p0 (getpoint "\nPazymekite bazini taska p0:"))
       (setq L (getdist "\nProfilio plotis L <30>:"))
       (if (null L) (setq b0 30))
       (setq L1 (getdist "\nprofilio plotis L1 <9>:"))
       (if (null L1) (setq L1 9))
       (setq H (getdist "\nprofilio aukstis H <30>:"))
       (if (null H) (setq h0 30))
       (setq c (getdist "\nprofilio aukstis c <3>:"))
       (if (null c) (setq c 3))
       (setq b (getdist "\nprofilio aukstis b <6>:"))
       (if (null b) (setq b 6))
       (setq R1 (getdist "\nuzapvalinimo spindulys R1 <10.5>:"))
       (if (null R1) (setq R1 10.5))
       (setq w (getdist "\npolilinijos plotis <0.5>:"))
       (if (null w) (setq w 0.5))
       (setq Fi (getdist "\nprofilio pasukimo kampas Fi <0.0>:"))
       (if (null Fi) (setq Fi 0.0)) 
        )
;--Taškų Koordinačių paskaičiavimas-----
(defun piont ()
       (setq p1 (polar p0 (dtr 90) H))
       (setq p2 (polar p1 0 L1))
       (setq p3 (list (car p2) (- (cadr p2) c)))
       (setq p4 (polar p3 (dtr 315)(* R1(sqrt 2)))
(setq p5 (polar p4 (dtr -315)(* R1(sqrt 2)))      
       (setq p6 (polar p5 (dtr -90) b0))
 )
;--Profilio braizymas--
(defun braiz ()
       (command "PLINE" p0 "w" w "" p1 p2 p3 "ARC" "ANGLE" "-90" p4 "ARC" "ANGLE" "90" p5 "b0" p6 p0 "")
       (setq PL1 (entlast)) 
       (command "ROTATE" PL1 "" p0 Fi)
       (steq PL2 (entnext PL1))
       (command "hatch" "ansi31" 1 0 PL1 "")
        )
;--Pagrindine programa-------------------------------------------
  --Pagrindine programa--
(defun C:PROF1 ()
      (dtr)
      (duom)
      (braiz)

the error starts from this line (setq p4 (polar p3 (dtr 315)(* R1(sqrt 2))) untill the bottom

Autolisp2.zip

Edited by SLW210
Added CODE TAGS!!!!!!!! Merry Christmas!
Posted

Welcome on board

I've found some unbalanced brackets in your code

Try edited lisp:

; -------------------------------------------------------
; profa.lsp
; Profilio braizymas
; DB0/3 gr. stud. G., Sveikataite
; D. Kalisinskas
; KTU, Inzinerines grafikos katedra.
; --DTR funkcijos ivedimas i programa-----
(defun dtr (alfa)
(* pi (/ alfa 180.0))
)
;Duomenu ivedimas: p0, L, L1, H, c, b, R1, W, Fi
(defun duom ()
(setq p0 (getpoint "\nPazymekite bazini taska p0:"))
(setq L (getdist "\nProfilio plotis L <30>:"))
(if (null L) (setq b0 30))
(setq L1 (getdist "\nprofilio plotis L1 <9>:"))
(if (null L1) (setq L1 9))
(setq H (getdist "\nprofilio aukstis H <30>:"))
(if (null H) (setq H 30));was ho
(setq c (getdist "\nprofilio aukstis c <3>:"))
(if (null c) (setq c 3))
(setq b (getdist "\nprofilio aukstis b <6>:"))
(if (null b) (setq b 6))
(setq R1 (getdist "\nuzapvalinimo spindulys R1 <10.5>:"))
(if (null R1) (setq R1 10.5))
(setq w (getdist "\npolilinijos plotis <0.5>:"))
(if (null w) (setq w 0.5))
(setq Fi (getdist "\nprofilio pasukimo kampas Fi <0.0>:"))
(if (null Fi) (setq Fi 0.0)) 
)
;--Tasku Koordinaciu paskaiciavimas-----
(defun piont ()
(setq p1 (polar p0 (dtr 90) H))
(setq p2 (polar p1 0 L1))
(setq p3 (list (car p2) (- (cadr p2) c)))
(setq p4 (polar p3 (dtr 315)(* R1(sqrt 2))))
(setq p5 (polar p4 (dtr -315)(* R1(sqrt 2)))) 
(setq p6 (polar p5 (dtr -90) b0))
)
;--Profilio braizymas--
(defun braiz ()
(command "PLINE" "_non" p0 "w" w "" "_non" p1 "_non" p2 "_non" p3 "ARC" "ANGLE" "-90" "_non" p4 "ARC" "ANGLE" "90" "_non" p5 "L" "_non" p6 "_non" p0 "")
(setq PL1 (entlast)) 
(command "ROTATE" PL1 "" p0 Fi)
(setq PL2 (entnext PL1))
(command "hatch" "ansi31" 1 0 PL1 "")
)
;--Pagrindine programa-------------------------------------------
(defun C:ROF1 ()
(duom)
(piont)
(braiz)
(princ)
)
(C:ROF1);<-- autorun for debug

Next time follow forum rules, please

Better yet to translate your prompts inside the code

on english

And also, put code like this:

 Your lisp text follow here [/ code];

Read what SLW210 had recommended

Posted

For anyone interested a unbalanced bracket checker

 

(defun c:chkbrk (/ opf bkt chekdfile rdctl wkfile currentln wln ltr ncln)
(setvar "cmdecho" 0)
(prompt "\nlook at end of line")
;(setq chekdfile (getstring "enter name of file :"))
(SETQ chekdfile (getfiled "Enter file name:" " " "LSP" 4))

(setq opf (open chekdfile "r"))
(setq bkt 0)
(setq blkl 0)
(setq rdctl 1)
(setq wkfile (open "c:\\acadtemp\\wow.lsp" "w"))

(setq currentln "a")
(while (/= blkl 6)
(setq currentln (read-line opf))
(if (= currentln nil)(setq currentln ""))
(if (= currentln "")(setq blkl (+ 1 blkl))(setq blkl 1))
(setq wln currentln)                                                        
(while (/= wln "")
       (setq ltr (substr wln 1 1))
       (setq wln (substr wln 2))
       (cond ((= (ascii ltr) 34) (if (= rdctl 0)(setq rdctl 1)(setq rdctl 0)))
               ((and (= ltr "(")(= rdctl 1))(setq bkt (+ bkt 1)))
               ((and (= ltr ")")(= rdctl 1))(setq bkt (- bkt 1)))
               ((and (= ltr ";")(= rdctl 1))(setq wln ""))
               ;(t (prompt ltr))
       )
)
(setq ncln (strcat currentln ";" (itoa bkt)
(princ (itoa bkt))
(if (= rdctl 0) "string open" "")))
(if (/= currentln "")(write-line ncln wkfile))
)
(close wkfile)
(close opf)
(prompt (strcat "open brakets= " (itoa bkt) "."))
)

(setq ang1 nil
     pt1 nil
     pt2 nil
     pt3 nil
     pt4 nil
     pt5 nil)

(princ)

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