fleshget Posted November 24, 2011 Share Posted November 24, 2011 hi there, i have a problem with this lisp. (while (>= cnt 0) (setq [color="red"]km[/color] (+ [color="red"]aramesafe[/color] [color="red"]bkm[/color]))) (write-line (strcat "\t\tNO " [color="red"]km[/color] " KOT 0.00000 0.00 0.00 0 0") txt) i cannot work this part i.e. (setq bkm 0) (setq aramesafe 20) (while (>= cnt 0) (setq km (+ aramesafe bkm))) add aramesafe value increase repeatly to the end like that: (write-line (strcat "\t\tNO " [color="red"]20[/color] " KOT 0.00000 0.00 0.00 0 0") txt) (write-line (strcat "\t\tNO " [color="red"]40[/color] " KOT 0.00000 0.00 0.00 0 0") txt) (write-line (strcat "\t\tNO " [color="red"]60[/color] " KOT 0.00000 0.00 0.00 0 0") txt) (write-line (strcat "\t\tNO " [color="red"]80[/color] " KOT 0.00000 0.00 0.00 0 0") txt) ... ... full of lisp here (defun myerror (e) (if (/= e "Function cancelled") (princ (strcat "\nError:" e)) ) (setvar "BLIPMODE" bm) (setvar "OSMODE" om) (setvar "EDGEMODE" em) (setq *error* olderr) (setvar "CMDECHO" 1) (princ) ) (defun C:SEV () (setq olderr *error* *error* myerror) (setvar "CMDECHO" 0) (setq om (getvar "OSMODE")) (setvar "OSMODE" 0) (setq bm (getvar "BLIPMODE")) (setvar "BLIPMODE" 0) (setq em (getvar "EDGEMODE")) (setvar "EDGEMODE" 0) (setq cl (getvar "clayer")) (command "layer" "make" "kesit" "color" "3" "kesit" "") (command "layer" "make" "kesit_sol" "color" "1" "kesit_sol" "") (command "layer" "make" "kesit_sag" "color" "5" "kesit_sag" "") (vl-load-com) (setq txt (open "C:\\ok.txt" "w")) (if (null (tblsearch "BLOCK" "PLALISP")) (progn (command "layer" "set" "kesit_sol" "") (entmake '((0 . "BLOCK") (2 . "KESITSOL") (70 . 64) (10 0.0 0.0 0.0))) (entmake '((0 . "LINE") (8 . "kesit_sol") (10 0.0 0.0 0.0) (11 0.0 0.1 0.0))) (entmake '((0 . "ENDBLK"))) (command "layer" "set" "kesit_sag" "") (entmake '((0 . "BLOCK") (2 . "KESITSAG") (70 . 64) (10 0.0 0.0 0.0))) (entmake '((0 . "LINE") (8 . "kesit_sag") (10 0.0 0.0 0.0) (11 0.0 0.1 0.0))) (entmake '((0 . "ENDBLK"))) ) ) (setq bkm (getdist (strcat "Başlangıç KM:"))) (if (= bkm nil)(setq bkm 0)) (setq eksen (entsel "\nEksen: ")) (redraw (car eksen) 3) (princ "\nSol: ") (setq sol (ssget)) (princ "\nSag: ") (setq sag (ssget)) (setq aramesafe 20) (if (null aramesafe) (setq aramesafe (getdist "\nAra Mesafe: ")) (setq genislik (getdist (strcat "\nAra Mesafe <" (rtos aramesafe 2 2) ">: ")))) (if genislik (setq aramesafe genislik)) (redraw (car eksen) 4) (command "layer" "set" "kesit" "") (command "MEASURE" eksen "BLOCK" "KESITSOL" "Y" aramesafe) (command "MEASURE" eksen "BLOCK" "KESITSAG" "Y" aramesafe) (setq ssetsol1 (ssget "X" '((2 . "KESITSOL")))) (setq ssetsag1 (ssget "X" '((2 . "KESITSAG")))) (setq cnt 0) (setq even T) (repeat (sslength ssetsol1) (setq entsol (ssname ssetsol1 cnt)) (setq ptxsol (cdr (assoc 10 (entget entsol)))) (command "EXPLODE" entsol) (command "chprop" "P" "" "layer" "kesit_sol" "") (setq ssetsol2 (ssget "P") entsol (ssname ssetsol2 0) pt1sol (cdr (assoc 10 (entget entsol))) pt2sol (cdr (assoc 11 (entget entsol))) ansol (angle pt1sol pt2sol) pt1sol (list entsol (polar pt1sol ansol 0.01)) pt2sol (list entsol (polar pt2sol (+ ansol pi) 0.01)) ) (setq entsag (ssname ssetsag1 cnt)) (setq ptxsag (cdr (assoc 10 (entget entsag)))) (command "EXPLODE" entsag) (command "chprop" "P" "" "layer" "kesit_sag" "") (setq ssetsag2 (ssget "P") entsag (ssname ssetsag2 0) pt1sag (cdr (assoc 10 (entget entsag))) pt2sag (cdr (assoc 11 (entget entsag))) ansag (angle pt1sag pt2sag) pt1sag (list entsag (polar pt1sag ansag 0.01)) pt2sag (list entsag (polar pt2sag (+ ansag pi) 0.01)) ) (command "EXTEND" sol "" pt1sol pt2sol "") (command "TRIM" eksen "" pt1sol "") (setq datasol (vlax-ename->vla-object entsol)) (setq lengsol (vla-get-length datasol)) (setq lilisol (rtos lengsol 2 3)) (command "ERASE" entsol "") (command "EXTEND" sag "" pt1sag pt2sag "") (command "TRIM" eksen "" pt1sag "") (setq datasag (vlax-ename->vla-object entsag)) (setq lengsag (vla-get-length datasag)) (setq lilisag (rtos lengsag 2 3)) (command "ERASE" entsag "") [color="red"](while (>= cnt 0) (setq km (+ aramesafe bkm)))[/color] (write-line (strcat "\t\tNO "[color="red"] km[/color] " KOT 0.00000 0.00 0.00 0 0") txt) (write-line (strcat lilisol"%D1,YKO") txt) (write-line (strcat lilisag"%D2,YKA") txt) (setq cnt (1+ cnt)) ) (close txt) (setvar "OSMODE" om) (setvar "BLIPMODE" bm) (setvar "EDGEMODE" em) (setq *error* olderr) (command "layer" "set" cl "") (setvar "CMDECHO" 1) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted November 24, 2011 Share Posted November 24, 2011 (while (>= cnt 0) (setq km (+ aramesafe bkm))) cnt variable is constant from the time you started the while loop it will remain as such or perhaps a typo error on your part . but then again even with this: (while [color=blue][b](>= cnt 0)[/b][/color] (setq km (+ aramesafe bkm)) (write-line (strcat "\t\tNO " km " KOT 0.00000 0.00 0.00 0 0") txt) (write-line (strcat lilisol"%D1,YKO") txt) (write-line (strcat lilisag"%D2,YKA") txt) [b][color=blue](setq cnt (1+ cnt))[/color][/b] ) You are increasing the value of cnt and your test expression "(>= cnt 0)" [greater than or equal to] will never evaluate to nil as you started with 0 (setq cnt (1+ cnt)) Quote Link to comment Share on other sites More sharing options...
fleshget Posted November 24, 2011 Author Share Posted November 24, 2011 @pBe my head messed up i cannot understand you exactly, hmm.. i customize already exist lisp files, i'm newbie yet there is cnt variable before repeat command. this logic may be wrong, i'm not sure. i want to increase bkm variable with aramesafe like that (setq [color="red"]bkm[/color] 0) [color="#9acd32"];; 0 or any integer[/color] (setq [color="red"]aramesafe[/color] 20) then km variable increasing like; first km value is 20 40 60 80 ... ... and it's will continue with repeat command. can u help me about that? sorry for my bad english :/ thanks.. Quote Link to comment Share on other sites More sharing options...
pBe Posted November 24, 2011 Share Posted November 24, 2011 @pBe my head messed up i cannot understand you exactly, hmm.. i customize already exist lisp files, i'm newbie yet there is cnt variable before repeat command. this logic may be wrong, i'm not sure. i want to increase bkm variable with aramesafe like that (setq [color=red]bkm[/color] 0) [color=#9acd32];; 0 or any integer[/color] (setq [color=red]aramesafe[/color] 20) then km variable increasing like; first km value is 20 40 60 80 ... ... and it's will continue with repeat command. can u help me about that? sorry for my bad english :/ thanks.. other issues: (setq [b][color=blue]km[/color][/b] (+ aramesafe bkm));<-- this will generate a real number (write-line (strcat "\t\tNO " [color=blue][b]km[/b][/color] " KOT 0.00000 0.00 0.00 0 0") txt);<-- this requires string (write-line (strcat "\t\tNO " [b][color=blue](rtos km 2 2)"[/color][/b] KOT 0.00000 0.00 0.00 0 0") txt);<--- this will set it right I'm guessing you can use lengsol or lengsag value to terminate the loop [color=blue][b][i](setq bkm (+ aramesafe bkm))[/i][/b][/color] (while [b][i][color=blue](or (< bkm lengsol) (< bkm lengsag))[/color][/i][/b] ;<---- depends (write-line (strcat "\t\tNO " (rtos [b][i][color=blue]bkm[/color][/i][/b] 2 2) " KOT 0.00000 0.00 0.00 0 0" ) txt ) (write-line (strcat (rtos lengsol 2 3) "%D1,YKO") txt) (write-line (strcat (rtos lengsag 2 3) "%D2,YKA") txt) [color=blue][b][i](setq bkm (+ aramesafe bkm))[/i][/b][/color] ) Quote Link to comment Share on other sites More sharing options...
fleshget Posted November 24, 2011 Author Share Posted November 24, 2011 (edited) (setq bkm (+ aramesafe bkm)) (while (or (< bkm lengsol) (< bkm lengsag)) ;<---- depends (write-line (strcat "\t\tNO " (rtos bkm 2 2) " KOT 0.00000 0.00 0.00 0 0" ) txt ) (write-line (strcat (rtos lengsol 2 3) "%D1,YKO") txt) (write-line (strcat (rtos lengsag 2 3) "%D2,YKA") txt) (setq bkm (+ aramesafe bkm)) ) there is a problem like that: this is work but it's not stop i'm check it now. (if "i'm doing right" (thanks a lot) (asking a lot)) edit: yea! thanks for help! there is no need while or repeat actually. because i can't stop it edited only one row like; (setq bkm (+ aramesafe bkm)) [color="#9acd32"];adding only this row.[/color] (write-line (strcat "\t\tNO " (rtos bkm 2 2) " KOT 0.00000 0.00 0.00 0 0") txt) (write-line (strcat (rtos lengsol 2 3) "%D1,YKO") txt) (write-line (strcat (rtos lengsag 2 3) "%D2,YKA") txt) (setq cnt (1+ cnt)) ) this lisp working now, thanks for all pBe, cheers! Edited November 24, 2011 by fleshget Quote Link to comment Share on other sites More sharing options...
pBe Posted November 25, 2011 Share Posted November 25, 2011 this lisp working now, thanks for all pBe, cheers! Glad you figured it out flesh. good for you Cheers Quote Link to comment Share on other sites More sharing options...
fleshget Posted November 25, 2011 Author Share Posted November 25, 2011 hi again, i modify this lisp and its working perfectly. but there is a small problem with measure command. adding blocks to pline with measure in the direction I want to, it's okay. but the process is moving in the reverse. please look up to attachments and try it, my english is not enough for explain this problem type command, "Başlangıç KM" type 0 select red pline in the middle press enter for 5 times thats ok. if you are selected red pline by the right end: the process is start from the right side, its right. but if you are selected red pline by the left end: its start from the right side again explained my problem, i hope.. thanks for helping, cheers.. added dwg and lisp file to attachments REV.dwg pla-rkyk.lsp Quote Link to comment Share on other sites More sharing options...
pBe Posted November 26, 2011 Share Posted November 26, 2011 i modify this lisp and its working perfectly. but there is a small problem with measure command. the measure command is dictated by the way the polylines are created. what you need to do is reverse the polyline: Use This or This Holler if you need help Quote Link to comment Share on other sites More sharing options...
fleshget Posted November 26, 2011 Author Share Posted November 26, 2011 YEAH! thanks so much pBe, you are my savior hails Quote Link to comment Share on other sites More sharing options...
pBe Posted November 26, 2011 Share Posted November 26, 2011 YEAH! thanks so much pBe, you are my savior hails Its all you fleshget. Nice routine BTW, I like the idea Quote Link to comment Share on other sites More sharing options...
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.