Jump to content

Last point in a lisp


Delta-Sword

Recommended Posts

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

Link to comment
Share on other sites

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")

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

just out of interest on this one

how can a command be inactive

 

surely if it is inactive it isnt doing anyhting ??

 

thanx

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...