Draw a Line between 2 points.
First let’s say we have to draw a line from Point p to Point q
So first of all you need to set these point values.
There are 2 methods to do this.
A. First by entering point values in Command line
Let’s say we want to start a line from origin, now we need to get this point values and set for x.
(setq p (getpoint “Type point values”) )
Type point values» 0,0
(0.0 0.0 0.0)
(setq q (getpoint “Type point values”) )
Type point values» 0,8
(0.0 8.0 0.0)
- Now run command Line from LISP
(command “LINE” p q )
A Line of 8 unit length is drawn in DraftSight from p to q points
B. Second by selecting points in GA.
- Now I have changed text “Type point values” to “Click in GA” just for representation only. You can set any text or leave it blank.
(setq p (getpoint “Click in GA”) )
Click in GA» (4.56809164 1.97751027 0.0)
: (setq q (getpoint “Click in GA”) )
Click in GA» (9.46322023 7.88829479 0.0)
- Now type Command Line
(command “Line” p q )
- This will create a Line from your specified points in GA and command is still in use to draw line with next point.
- If you want to stop this line command at this point then change command line code as below
(command “Line” p q “”)
- This will create a line and returns value as Nil.
- Now we will store this program in our list file.
- Open Text file from Notepad ++ choose file type as .lsp save it in Location “D:\LISP Files” (This is just a reference location for our tutorials, you can choose any) with name “drawLine”
Write a program as below:
(defun drawLine ()
(setq p (getpoint “Click first point in GA”) )
; Get first point of line
(setq q (getpoint ” Click second point in GA “) )
;Get second point of line
(command “LINE” p q “”)
; Draw a line in GA
Now, In DraftSight type in Command line
It will return as DRAWLINE
Now that you have this LISP command to use for above program.
- We have to use () to run this command, we can avoid this by inputing C: in our program when we define drawLine function so it will be c:drawline()
- When we run this lisp command then return text as nil to remove this add (princ) next to your comment ; Draw a line in GA