home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Share Gallery 1
/
share_gal_1.zip
/
share_gal_1
/
GR
/
GR505.ZIP
/
LSP.EXE
/
NEWPLI.LSP
< prev
next >
Wrap
Text File
|
1989-09-10
|
4KB
|
131 lines
; NEWPLINE is an lisp function for a new AutoCAD command.
; Newpline prompts the user for a list of "control" points that
; are the vertices of a Pline. The user is prompted for the
; starting direction of the Pline. A command list is
; constructed and evaluated, which draws the Pline. A slow but
; effective "drag" option has been implemented, to change the
; shape of the Pline by dragging the starting direction.
; Multiple Plines can be drawn using the same list of control
; points, with different starting directions.
; This function was originally created for use in drawing smooth
; curves for boat hulls.
;
; Written by Brad Zehring 73417,705 12/29/86
; PC Consulting
; 1519 San Pascual Santa Barbara, CA 93101 (805) 965-3160
; Comments and suggestions are welcome.
; Get_start_ang returns the angle in degrees from point f_p
; to a user-selected point.
(defun get_start_ang ()
(setq start_ang
(/ (* 180 (getangle f_p "\nTangent direction: ")) pi)
)
)
; Get_point_list prompts for and creates a list of user-
; selected points, variable point_list. Variable f_p is bound
; to the first point selected. Point_list is reversed to
; reflect the true order of points selected.
(defun get_point_list (/ x)
(setq point_list nil)
(setq x (getpoint "\nFrom point: "))
(setq f_p x)
(while x
(setq point_list (cons x point_list))
(setq x (getpoint "\nTo point: "))
)
(setq point_list (reverse point_list))
)
; Make_quote_list takes one argument which must be a list, and
; returns a list, variable quote_list, that quotes each element
; from the original argument.
(defun make_quote_list (x / y)
(if (listp x)
(progn
(setq quote_list nil)
(setq x (reverse x))
(while x
(setq y (cons 'quote (list (car x))))
(setq quote_list (cons y quote_list))
(setq x (cdr x))
)
)
(prompt "\nArgument to Make_quote_list function not a list. ")
)
)
; Make_com_list creates a Pline command list from the points
; stored in quote_list and the direction obtained from
; get_start_ang.
(defun make_com_list ()
(setq com_list
(append
(append '(command "pline")
(append (list (car quote_list) '"A" '"D" (get_start_ang))
(cdr quote_list)
)
)
'(""))
)
)
; Drag_newpl implements a rudimentary and ***SLOW*** "drag"
; feature. Recommended only for fast AT class machines.
(defun drag_newpl (/ reading new_ang drag_test)
(setq drag_test
(strcase (getstring "\nDrag the arcs (y/n)? <Y>: "))
)
(if (= drag_test '"N") (setq drag_test nil) (setq drag_test t))
(while drag_test
(entdel (entlast))
(setq reading (grread t))
(setq new_ang
(/ (* 180 (angle f_p (cadr reading))) pi)
)
(setq com_list
(subst new_ang (nth 5 com_list) com_list)
)
(eval com_list)
(if (= (car reading) 3) (setq drag_test nil))
)
)
(defun c:newpline ()
(setvar "cmdecho" 0)
(graphscr)
(get_point_list)
(make_quote_list point_list)
(setq user_test T)
(while user_test
(make_com_list)
(eval com_list)
(drag_newpl)
(setq user_test
(strcase
(getstring "\nTry again (y/n)? <Y>: ")
)
)
(if (= user_test '"N")
(setq user_test nil)
(progn
(setq user_test T)
(setq del_test
(strcase
(getstring "\nErase last pline (y/n)? <Y>: ")
)
)
(if (not (= del_test '"N"))
(command "erase" "l" "")
)
)
)
)
)