alrawy201050 Posted March 13, 2016 Posted March 13, 2016 Lisp routine works but unknown command is displayed I.LSP Quote
marko_ribar Posted March 13, 2016 Posted March 13, 2016 You can use code tags to display lisp as text so we can see routine without downloading attachment - lisp is 4-5 KB, so it will be in limits of maximum allowed characters for this site... Code Tags : [noparse] Your code here ... [/noparse] Quote
BIGAL Posted March 13, 2016 Posted March 13, 2016 Code is posted twice and you need to use the code tags. Obvious error is (close) you need to state the file you are closing. A couple of suggestions in your code make all your layers at the start and use (clayer "yourlayername") changing properties is an extra step. Make your variables local (defun run ( / pt1 pt2 ..............) You can nest lisp if you want for simple tasks you are converting a variable from a real to a string sometimes can be a problem, note code tags use the # (setq x (car p)) (setq x (rtos x 2 4)) (setq x (strcat x " ")) (setq x (strcat (rtos (car p) 2 4) " ")) (setq y (strcat (rtos (cadr p) 2 4) " ")) Quote
alrawy201050 Posted March 15, 2016 Author Posted March 15, 2016 (defun run () (setq pll (getstring "\nget name of new file (name.ext) :")) (setq pl (open pll "w")) (setq e (getstring "\nget no. of first Point :")) (setq a (atoi e)) (while (setq p (getpoint "\nselect point :")) (setq v1 (strcat "\n " (itoa a) " ")) (setq d (polar p (/ (* 1 pi) 2) 4.5)) (command "layer" "m" "number" "c" "3" "" "") (command "text" "m" d 3.0 0.0 a) (setq num (entlast)) (command "change" num "" layer "" number "") (command "layer" "m" "point" "c" "1" "" "") (command "point" p) (setq pt (entlast)) (command "change" pt "" layer "" point "") (princ v1 pl) (setq x (car p)) (setq x (rtos x 2 4)) (setq x (strcat x " ")) (setq v2 x) (princ v2 pl) (setq y (cadr p)) (setq y (rtos y 2 4)) (setq y (strcat y " ")) (setq v3 y) (princ v3 pl) (setq a (+ a 1)) ) (command "layer" "m" "txt" "c" "5" "" "") (close pl) (redraw) (princ) ) (defun c:I () (run) (setq fil (getstring "\nget name of the file (name.ext) :")) (setq p1 (getpoint "select insertion point :")) (setq p2 (polar p1 0.0 30.0)) (setq p3 (polar p1 0.0 100.0)) (setq p4 (polar p1 (/ (* -1 pi) 2) 20.0)) (setq p5 (polar p4 0.0 30.0)) (setq p6 (polar p4 0.0 65.0)) (setq p7 (polar p4 0.0 100.0)) (setq p8 (polar p2 (/ (* -1 pi) 2) 10.0)) (setq p9 (polar p8 0.0 35.0)) (setq p10 (polar p8 0.0 70.0)) (setq p11 (polar p8 (* -1 pi) 15.0)) (setq p12 (polar p8 (/ pi 2) 5.0)) (setq p13 (polar p8 (/ (* -1 pi) 2) 5.0)) (setq p14 (polar p12 0.0 35.0)) (setq p15 (polar p13 0.0 17.5)) (setq p16 (polar p13 0.0 52.5)) (setq p1- (polar p1 (/ (* -1 pi) 2) 2000000000.0)) (command "text" "m" p11 3.0 0.0 "POINT NO.") (command "text" "m" p14 3.0 0.0 "COORDINATES") (command "text" "m" p15 3.0 0.0 "X") (command "text" "m" p16 3.0 0.0 "Y") (command "line" p1 p4 "") (setq L14 (entlast)) (command "line" p2 p8 p5 "") (setq L285 (entlast)) (command "line" p9 p6 "") (setq L96 (entlast)) (command "line" p3 p10 p7 "") (setq L3107 (entlast)) (command "line" p1 p2 p3 "") (command "line" p8 p9 p10 "") (command "pline" p4 p5 p6 p7 "") (setq L4567 (entlast)) (setq fill (open fil "r")) (read-line fill) (setq new ()) (setq j 0.0) (setq p44 p4) (while (setq S (read-line fill)) (setq pt (polar p44 (/ (* -1 pi) 2) (+ 5 j))) (setq pt1 (polar pt 0.0 15.0)) (setq pt2 (polar pt 0.0 47.5)) (setq pt3 (polar pt 0.0 82.5)) (setq t1 (substr S 1 4)) (setq t2 (substr S 5 16)) (setq t3 (substr S 21 32)) (command "text" "m" pt1 3.0 0.0 t1) (command "text" "m" pt2 3.0 0.0 t2) (command "text" "m" pt3 3.0 0.0 t3) (setq p4 (polar p4 (/ (* -1 pi) 2) 10.0)) (setq p5 (polar p5 (/ (* -1 pi) 2) 10.0)) (setq p6 (polar p6 (/ (* -1 pi) 2) 10.0)) (setq p7 (polar p7 (/ (* -1 pi) 2) 10.0)) (command "offset" (+ j 10.0) (list L4567 p4) p1- "") (setq new (entlast)) (command "extend" new "" (list L14 P4) "") (command "extend" new "" (list L285 p5) "") (command "extend" new "" (list L96 p6) "") (command "extend" new "" (list L3107 p7) "") (setq j (+ j 10.0)) ) (close) ) Quote
alrawy201050 Posted March 15, 2016 Author Posted March 15, 2016 This is what i get on my screen. Unknown command "i". Press F1 for help. Unknown command "i". Press F1 for help. why this happen ? can anyone help Quote
BIGAL Posted March 16, 2016 Posted March 16, 2016 Did you read my post a vlide check [CHECKING TEXT loading...] . ; warning: too few arguments: (CLOSE) ; Check done. Quote
alrawy201050 Posted March 17, 2016 Author Posted March 17, 2016 thank you bigal but i dont know anything about lisp so can you fix the code and send it to me Quote
marko_ribar Posted March 17, 2016 Posted March 17, 2016 I think he is pointing to your last syntax (close)... Should be (close fill)... Quote
alrawy201050 Posted March 18, 2016 Author Posted March 18, 2016 i change it but still this massage appear Command: I get name of new file (name.ext) :\adam877.txt get no. of first Point :1 select point :layer Current layer: "0" Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: m Enter name for new layer (becomes the current layer) : number Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: c New color [Truecolor/COlorbook] : 3 Enter name list of layer(s) for color 3 (green) : Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Command: text Current text style: "Standard" Text height: 2.5000 Annotative: No Justify: Left Specify start point of text or [Justify/Style]: m Specify middle point of text: Specify height : 3.000000000000000 Specify rotation angle of text : 0.000000000000000 Enter text: 1 Command: change Select objects: 1 found Select objects: Specify change point or [Properties]: Command: I Unknown command "I". Press F1 for help. Command: Command: I Unknown command "I". Press F1 for help. Command: layer Current layer: "number" Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: m Enter name for new layer (becomes the current layer) : point Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: c New color [Truecolor/COlorbook] : 1 Enter name list of layer(s) for color 1 (red) : Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Command: point Current point modes: PDMODE=0 PDSIZE=0.0000 Specify a point: Command: change Select objects: 1 found Select objects: Specify change point or [Properties]: Command: I Unknown command "I". Press F1 for help. Command: Command: I Unknown command "I". Press F1 for help. Command: select point :*Cancel* Quote
marko_ribar Posted March 18, 2016 Posted March 18, 2016 Here is revision of your code by me... Wonder why someone haven't tried to revise it till now... (defun c:I ( / *adoc* *error* run fil p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p1- L14 L285 L96 L3107 L4567 fill new j p44 S pt pt1 pt2 pt3 t1 t2 t3 ) (vl-load-com) (vla-startundomark (setq *adoc* (vla-get-activedocument (vlax-get-acad-object)))) (defun *error* ( msg ) (vla-endundomark *adoc*) (if msg (prompt msg) ) (princ) ) (defun run ( / pll pl a p v1 d num pt x v2 y v3 ) (setq pll (getstring "\nSpecify name of new file (name.ext) : ")) (setq pl (open pll "w")) (setq a (getint "\nSpecify no. of first Point : ")) (while (setq p (getpoint "\nPick or specify point (ENTER - FINISH) : ")) (setq v1 (strcat "\n " (itoa a) " ")) (setq d (polar p (/ pi 2) 4.5)) (if (not (tblsearch "LAYER" "number")) (command "_.layer" "_m" "number" "_c" "3" "" "") ) (command "_.text" "_m" "_non" d 3.0 0.0 a) (setq num (entlast)) (command "_.change" num "" "_p" "_la" "number" "") (if (not (tblsearch "LAYER" "point")) (command "_.layer" "m" "point" "c" "1" "" "") ) (command "_.point" "_non" p) (setq pt (entlast)) (command "_.change" pt "" "_p" "_la" "point" "") (princ v1 pl) (setq x (car p)) (setq x (rtos x 2 4)) (setq x (strcat x " ")) (setq v2 x) (princ v2 pl) (setq y (cadr p)) (setq y (rtos y 2 4)) (setq y (strcat y " ")) (setq v3 y) (princ v3 pl) (setq a (+ a 1)) ) (command "_.layer" "_m" "txt" "_c" "5" "" "") (close pl) (redraw) (princ) ) (run) (setq fil (getstring "\nSpecify name of the file (name.ext) : ")) (setq p1 (getpoint "\nPick or specify insertion point : ")) (setq p2 (polar p1 0.0 30.0)) (setq p3 (polar p1 0.0 100.0)) (setq p4 (polar p1 (/ (* -1 pi) 2) 20.0)) (setq p5 (polar p4 0.0 30.0)) (setq p6 (polar p4 0.0 65.0)) (setq p7 (polar p4 0.0 100.0)) (setq p8 (polar p2 (/ (* -1 pi) 2) 10.0)) (setq p9 (polar p8 0.0 35.0)) (setq p10 (polar p8 0.0 70.0)) (setq p11 (polar p8 (* -1 pi) 15.0)) (setq p12 (polar p8 (/ pi 2) 5.0)) (setq p13 (polar p8 (/ (* -1 pi) 2) 5.0)) (setq p14 (polar p12 0.0 35.0)) (setq p15 (polar p13 0.0 17.5)) (setq p16 (polar p13 0.0 52.5)) (setq p1- (polar p1 (/ (* -1 pi) 2) 2000000000.0)) (command "_.text" "_m" "_non" p11 3.0 0.0 "POINT NO.") (command "_.text" "_m" "_non" p14 3.0 0.0 "COORDINATES") (command "_.text" "_m" "_non" p15 3.0 0.0 "X") (command "_.text" "_m" "_non" p16 3.0 0.0 "Y") (command "_.line" "_non" p1 "_non" p4 "") (setq L14 (entlast)) (command "_.line" "_non" p2 "_non" p8 "_non" p5 "") (setq L285 (entlast)) (command "_.line" "_non" p9 "_non" p6 "") (setq L96 (entlast)) (command "_.line" "_non" p3 "_non" p10 "_non" p7 "") (setq L3107 (entlast)) (command "_.line" "_non" p1 "_non" p2 "_non" p3 "") (command "_.line" "_non" p8 "_non" p9 "_non" p10 "") (command "_.pline" "_non" p4 "_non" p5 "_non" p6 "_non" p7 "") (setq L4567 (entlast)) (setq fill (open fil "r")) (read-line fill) (setq j 0.0) (setq p44 p4) (while (setq S (read-line fill)) (setq pt (polar p44 (/ (* -1 pi) 2) (+ 5 j))) (setq pt1 (polar pt 0.0 15.0)) (setq pt2 (polar pt 0.0 47.5)) (setq pt3 (polar pt 0.0 82.5)) (setq t1 (substr S 1 4)) (setq t2 (substr S 5 16)) (setq t3 (substr S 21 32)) (command "_.text" "_m" "_non" pt1 3.0 0.0 t1) (command "_.text" "_m" "_non" pt2 3.0 0.0 t2) (command "_.text" "_m" "_non" pt3 3.0 0.0 t3) (setq p4 (polar p4 (/ (* -1 pi) 2) 10.0)) (setq p5 (polar p5 (/ (* -1 pi) 2) 10.0)) (setq p6 (polar p6 (/ (* -1 pi) 2) 10.0)) (setq p7 (polar p7 (/ (* -1 pi) 2) 10.0)) (command "_.offset" (+ j 10.0) (list L4567 p4) p1- "") (setq new (entlast)) (command "_.extend" new "" (list L14 P4) "") (command "_.extend" new "" (list L285 p5) "") (command "_.extend" new "" (list L96 p6) "") (command "_.extend" new "" (list L3107 p7) "") (setq j (+ j 10.0)) ) (close fill) (*error* nil) ) HTH, M.R. Quote
alrawy201050 Posted March 18, 2016 Author Posted March 18, 2016 thank you very much ....you don't know how much this help me ....thank you again Quote
alrawy201050 Posted March 18, 2016 Author Posted March 18, 2016 it works perfect...but i want ask you about something ..how i can control in text height cos it sometime became so big? Quote
marko_ribar Posted March 18, 2016 Posted March 18, 2016 it works perfect...but i want ask you about something ..how i can control in text height cos it sometime became so big? You can try determining pixel size and adjust text size according to current zoom/view level... 1 pixel size = (/ (getvar 'viewsize) (cadr (getvar 'screensize))) Quote
alrawy201050 Posted March 18, 2016 Author Posted March 18, 2016 thank you marko ..but i want ask you about something else ..this lisp to get x y coordinates can we make it get z too ? Quote
marko_ribar Posted March 18, 2016 Posted March 18, 2016 Well that table is drawn, you'll have to work on it - it needs additional column for z... As for getting points, function (getpoint) works fine and for 3D picking, but again you'll have to add info for z and in output file you specify : (run) sub needs also revisions for this reason... Quote
BIGAL Posted March 18, 2016 Posted March 18, 2016 Alrawy201050 Just for your info Command: changeSelect objects: 1 found Select objects: Specify change point or [Properties]: Command: I When this happens it means that the code has tripped over on say a extra or a totally incorrect value has been supplied say a number instead of a string, lisps keeps going on passing answers, TEXT is a good example you have two different ways in a style with or without height set and it means in a program you have 1 less required looks like what is happening here hence the extra enter repeats last command which was I. Quote
Tomislav Posted June 16, 2016 Posted June 16, 2016 Hi, just wanted to say thanx to Marko and Bigal...i had the same problems as Alrawy201050 and finally solved them... Quote
Recommended Posts
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.