sanjeeve Posted October 19, 2014 Share Posted October 19, 2014 Hi I want draw lines it has create new layer and snap end point and Ortho on once I right click or cancel it has to go back to old layer and snap off and Ortho off Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 19, 2014 Share Posted October 19, 2014 Try the attached modified version of my Layer Director application. Lee LayerDirectorV1-2-1.lsp Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 19, 2014 Author Share Posted October 19, 2014 Hi I want lisp to draw line create new layer and Ortho on snap end One I right click or cancel it has to go back old layer and Ortho and snap off Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 19, 2014 Author Share Posted October 19, 2014 (edited) This what wrote it is not working any one help me to fix (define c:line() (setq a( getvar "player")) (setvar "Ortho" 1) (setvar "snap" 1) (command "line") (setvar "player" a) (setvar "Ortho" 0) (setvar "snap" 0) ) Edited October 27, 2014 by SLW210 Code Tags Added! Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 19, 2014 Share Posted October 19, 2014 You already started a thread on this topic that Lee Mac responded to. There is no need to create a new thread every time you respond as it just causes confusion. Thank you. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 20, 2014 Share Posted October 20, 2014 (edited) Sanjeeve 1st comment dont use c:line as line is a reserved word and you may have problems, (defun c:lll () (setq a( getvar "clayer")) (setvar "Ortho" 1) (setvar "snap" 1) ;(command "line") ; create line by picking points press enter when finished (command "_line") (while (= (getvar "cmdactive") 1 ) (command "pause") ) (setvar "clayer" a) (setvar "Ortho" 0) (setvar "snap" 0) ) Edited October 26, 2014 by BIGAL Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 20, 2014 Share Posted October 20, 2014 Moderator can you put all sanjeeve post to say 1 new post this is 3rd go. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 20, 2014 Share Posted October 20, 2014 Moderator sorry 4th time post Quote Link to comment Share on other sites More sharing options...
MSasu Posted October 20, 2014 Share Posted October 20, 2014 To review your code, please check my comments: ([color=red]define[/color] [color=magenta]c:line[/color]() ;bad function name, should be DEFUN; pay attention to redefining built-in commands (setq a( getvar "[color=red]player[/color]")) ;the name of the variable is VPLAYER (setvar "[color=red]Ortho[/color]" 1) ;the name of the variable is ORTHOMODE (setvar "[color=red]snap[/color]" 1) ;the name of the variable is SNAPMODE (command "line") ;this call will not allow to reach following statements, thus restoring environment will fails (setvar "[color=red]player[/color]" a) ;see above (setvar "[color=red]Ortho[/color]" 0) ;see above (setvar "[color=red]snap[/color]" 0) ;see above ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 20, 2014 Share Posted October 20, 2014 Msasu see my comments and Remarks this question is posted 4 times like you I have posted an answer on one of them. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted October 20, 2014 Share Posted October 20, 2014 Posts and threads merged. Please only ask your question once, patience is a virtue. Please also, read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 21, 2014 Author Share Posted October 21, 2014 Thanks a lot for your help I am new to this site and I want to learn lisp online help I wrote that thanks again Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 22, 2014 Author Share Posted October 22, 2014 Sanjeeve 1st comment dont use c:line as line is a reserved word and you may have problems, (define c:lll () (setq a( getvar "clayer")) (setvar "Ortho" 1) (setvar "snap" 1) ;(command "line") ; create line by picking points press enter when finished (command "_line") (while (= (getvar "cmdactive") 1 ) (command pause ) (setvar "clayer" a) (setvar "Ortho" 0) (setvar "snap" 0) ) This is not working why Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 23, 2014 Share Posted October 23, 2014 Sorry my fault if your learning lisp, look at 1st line it should have been Defun, I edited my post. Quote Link to comment Share on other sites More sharing options...
MSasu Posted October 23, 2014 Share Posted October 23, 2014 This is not working why Please check the post #9 where I added comments to your code to allow you understand what prevent it to work; then check also what BIGAL proposed for line repetitively input and those should alow you to debug. Please don't forget that you will benefit more if you will understand what was wrong then from just getting the fixed code. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 23, 2014 Share Posted October 23, 2014 Perhaps the following example will also help you: (defun c:myline ( / lay val var ) ;; Layer for Lines: (setq lay "My Line Layer") ;; Store current system variable values (setq var '(cmdecho clayer orthomode osmode) val (mapcar 'getvar var) ) ;; end SETQ ;; Suppress command-line output (setvar 'cmdecho 0) ;; Create/set/thaw/turn on/unlock the required layer (command "_.-layer" "_m" lay "_t" lay "_on" lay "_u" lay "") ;; Set other system variable values (setvar 'orthomode 1) ;; Ortho ON (setvar 'osmode 1) ;; Snap set to Endpoint (setvar 'cmdecho 1) ;; Now we want the command-line output ;; Invoke the LINE command (command "_.line") ;; While the command is active (while (= 1 (logand 1 (getvar 'cmdactive))) ;; Pause for user input (vl-cmdf "\\") ;; vl-cmdf is used to test the validity of the user input ;; before submitting it to the command-line. ) ;; end WHILE ;; Reset system variable values (mapcar 'setvar var val) ;; Suppress the return of the last evaluated expression (princ) ) ;; end DEFUN Please take some time to carefully read the comments. Lee Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 26, 2014 Author Share Posted October 26, 2014 Sanjeeve 1st comment dont use c:line as line is a reserved word and you may have problems, (defun c:lll () (setq a( getvar "clayer")) (setvar "Ortho" 1) (setvar "snap" 1) ;(command "line") ; create line by picking points press enter when finished (command "_line") (while (= (getvar "cmdactive") 1 ) (command pause) ) (setvar "clayer" a) (setvar "Ortho" 0) (setvar "snap" 0) ) yes, I change that to defun it is not working Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 26, 2014 Author Share Posted October 26, 2014 Hi Lee Thanks alot man this save my time it is working for me Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 26, 2014 Share Posted October 26, 2014 Hi Lee Thanks alot man this save my time it is working for me You're welcome sanjeeve - Be sure to read the comments so that you have a good understanding of what the code is doing. Lee Quote Link to comment Share on other sites More sharing options...
sanjeeve Posted October 28, 2014 Author Share Posted October 28, 2014 You're welcome sanjeeve - Be sure to read the comments so that you have a good understanding of what the code is doing. Lee Yes I am able to understand bit I could write simple lisp when ever I put two or more commands together it is not working I am tryin to under stand while and progan Normally to create new layer I use (command "layer" "myline" "color" "red" "" "") but I couldn't see that line in you lisp but it create layer how 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.