Delta-Sword Posted April 2, 2009 Share Posted April 2, 2009 hi i am very new to lisps i only started looking at them today and i am wondering how to use the last selected point so i draw a line which is simple but how do i select one more point and it draws a line from the end of the first line to the new point and keep doing this for any number of points Thanx for the help if i havnt explain very well i will post what i have so far Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 2, 2009 Share Posted April 2, 2009 Well, there are a couple of ways you could accomplish this: Easiest being: (command "_line") (while (> (getvar "CMDACTIVE") 0) (command pause)) But to just retrieve the last point clicked: (getvar "lastpoint") Quote Link to comment Share on other sites More sharing options...
haustab Posted April 2, 2009 Share Posted April 2, 2009 and also take a look at getpoint (setq P1 (getpoint "\npick a point: ")) Quote Link to comment Share on other sites More sharing options...
Delta-Sword Posted April 2, 2009 Author Share Posted April 2, 2009 thanx lee max that was exactly what i was looking for the only thing now is my command will not finish unless i press esc ( it doesnt finish when i press return) any help on this wld be apreciated Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 2, 2009 Share Posted April 2, 2009 Could you post your routine, and I shall check for errors - the code I posted should stop if enter is pressed. Quote Link to comment Share on other sites More sharing options...
Delta-Sword Posted April 2, 2009 Author Share Posted April 2, 2009 i cant post it as an attachment for some reason my work computer wnt let me but here is the text i have (defun c:3point () ; define the function (setq a (getpoint "\nEnter First Point : ")) ; get the first point (setq b (getpoint "\nEnter Next Point : ")) ;get the second point (command "line" a b "") ;draw the line (while (setq c (getvar "lastpoint")) (setq d (getpoint "\nEnter Next Point : ")) (command "line" c d "") ;draw the line ) (princ) ;clean running ) ;end defun (princ) ;clean loading By the way the reason for this is to learn a bit about lisps and not actually something practical at the moment (hence y it is basically a line command ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 2, 2009 Share Posted April 2, 2009 I would just simplify it to this: (defun c:3point () (command "_line") (while (> (getvar "CMDACTIVE") 0) (command pause)) (princ)) Quote Link to comment Share on other sites More sharing options...
Delta-Sword Posted April 2, 2009 Author Share Posted April 2, 2009 thanks a lot lee mac jus one thing could you pleasse explain the "while " part of the lips and the "command pause" as i have no idea what they do and i am aiming be able to write my own. thanx again tho a big insight i had a lot of stuff ireally didnt need Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 2, 2009 Share Posted April 2, 2009 Not a problem - if you still have questions, just ask (defun c:3point () ; Define the Function - no local variables or arguments in this one, so nothing in the brackets (command "_line") ; Invoke the Line command (merely prints "line" to the command line. (while ; While the following is true (> (getvar "CMDACTIVE") 0) ; The variable "CMDACTIVE" determines whether a command is active or not, i.e, while the line command ; is active... (command pause)) ; print a "pause" to the command line (hence pause for user input. (princ)) ;; exit cleanly. Quote Link to comment Share on other sites More sharing options...
Delta-Sword Posted April 2, 2009 Author Share Posted April 2, 2009 just out of interest on this one how can a command be inactive surely if it is inactive it isnt doing anyhting ?? thanx Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 2, 2009 Share Posted April 2, 2009 just out of interest on this one how can a command be inactive surely if it is inactive it isnt doing anyhting ?? thanx Exactly - I invoke the line command, then, while the line command is still prompting for points - i.e. it is active, I print a pause to the command line., Until the user doesn't supply a point and hence the command finishes and is inactive. 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.