Hi guys,
for the insert code i get the answer " error: bad argument type: stringp nil " . I tried to read it in the forum history but i didn't helped me.
(defun CreateEbeneLayer (Mc / :EntmakeLayer :AddLeadingZeros dlt i) (defun :EntmakeLayer (name color /) (if (not (tblobjname "LAYER" name)) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 name) (cons 62 color) '(70 . 0))))) (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits ;a string (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a)) (setq dlt (/ 360. Mc) i 0.) (command "_pline") (setq winkel 0) (setq j 0) (while (< i 360) (:EntmakeLayer (setq layname (strcat "C" (:AddLeadingZeros (rtos i 2 0) 3) ; = x "-C" (:AddLeadingZeros (rtos (+ i 180) 2 0) 3) ; = y "-EBENE")) 7) ; color ;------------------------- progn( (setq zeile(read-line eulum)) (setq laenge(atof zeile)) (setq winkel(/(* i Dg PI) 180)) (setq sinuswert(sin winkel)) (setq cosinuswert(cos winkel)) (setq x-wert(* laenge cosinuswert)) (setq y-wert(* laenge sinuswert)) (setq punkt(list x-wert y-wert)) (command punkt) );PROGN (setq j (+ j Ng)) ;------------------------- (setq i (+ i dlt)) );WHILE (command "") (close eulum) (princ) ) ;-----------
Is there a debugging software for AutoLISP or does someone see the mistake in the code? By the way i think the mistake must be between the inner dotted line comment.
Solved! Go to Solution.
Solved by martti.halminen. Go to Solution.
I think i found the problem.
(setq zeile(read-line eulum)) (setq laenge(atof zeile))
after taking some loops read-line reached the end of the .txt file and reads nil.
So i need an if command which controls if read-line reads nil?
I tried like:
(setq zeile( (if (= read-line eulum nil) (... something like break out of the loop or goto...)) );SETQ ZEILE (setq laenge(atof zeile))
Does somebody know how to continue?
Perhaps like this...
(defun CreateEbeneLayer (Mc / :EntmakeLayer :AddLeadingZeros dlt i) (defun :EntmakeLayer (name color /) (if (not (tblobjname "LAYER" name)) (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 name) (cons 62 color) '(70 . 0))))) (defun :AddLeadingZeros (a d / b) ;add zeros to 'd' many digits ;a string (strcat (substr "000000000" 1 (if (>= d (setq b (strlen (itoa (fix (atof a)))))) (- d b) 0)) a)) (setq dlt (/ 360. Mc) i 0.) (command "_pline") (setq winkel 0) (setq j 0) (while (< i 360) (:EntmakeLayer (setq layname (strcat "C" (:AddLeadingZeros (rtos i 2 0) 3) ; = x "-C" (:AddLeadingZeros (rtos (+ i 180) 2 0) 3) ; = y "-EBENE")) 7) ; color ;------------------------- (if (setq zeile (read-line eulum)) (progn (setq laenge(atof zeile)) (setq winkel(/(* i Dg PI) 180)) (setq sinuswert(sin winkel)) (setq cosinuswert(cos winkel)) (setq x-wert(* laenge cosinuswert)) (setq y-wert(* laenge sinuswert)) (setq punkt(list x-wert y-wert)) (command "_none" punkt) ) ; progn ) ; if (setq j (+ j Ng)) ;------------------------- (setq i (+ i dlt)) );WHILE (command "") (close eulum) (princ) ) ;-----------
@Anonymous wrote:
I think i found the problem.
after taking some loops read-line reached the end of the .txt file and reads nil.
Does somebody know how to continue?
Hi ruppelr,
in your code you are reading lines from eulum, and close eulum, but you are not opening the file...???
To prevent an empty line readind a txt file use an 'while'
(while (setq zeile (read-line eulum))
(setq laenge (atof zeile))
(setq winkel (/ (* i Dg PI) 180))...
Read those Lee Mac's tutorials
Post a sample '*.txt' file.
Hope this helps,
Henrique
Re debugging software: VLIDE has a debugger, you have that already.
So, type VLIDE on the ACAD command line, and in the dialog that opens set Debug>Break On Error checked and load your program.
Then return to AutoCAD, leaving the VLIDE dialog open.
Now run your program, and when it gets to the error, go in VLIDE to Debug>Last Break Source.
- reading the VLIDE documentation wouldn't hurt, either.
You have at least one other error in your program: progn( does odd things, you need (progn at that location.
Bypassing the NIL: try something like this:
(progn (setq zeile(read-line eulum)) (if zeile (progn (setq laenge(atof zeile)) (setq winkel(/(* i Dg PI) 180)) (setq sinuswert(sin winkel)) (setq cosinuswert(cos winkel)) (setq x-wert(* laenge cosinuswert)) (setq y-wert(* laenge sinuswert)) (setq punkt(list x-wert y-wert)) (command punkt))) );PROGN
--
Can't find what you're looking for? Ask the community or share your knowledge.