home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
felixcad
/
fcaddata.z
/
FLX_SPLN.LSP
< prev
next >
Wrap
Lisp/Scheme
|
1996-10-02
|
9KB
|
265 lines
;;; FLX_SPLN.LSP
;;; ===========================================================
;;; (C)opyright: Felix Computer Aided Technologies GmbH 1995-96
;;; Created: June 29, 1996 / vp
;;; Modified: Sept 29, 1996 / vp
;;; ===========================================================
;;; Commands: SPLINE, PCURVE
;;; ===========================================================
(defun FLX_SPLINE ( / prt_list tmp fn e1 e2 i1)
(defun *ERROR* (msg / msg)
(if (or (= msg "User break")
(= msg "Abbruch durch den Nutzer")
)
(princ)
(princ msg)
)
(setq *error* nil)
(if fn (XUNLOAD fn))
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Prompt List
(setq prt_list (list
"File not found: \n"
"Alert"
"Decurve"
"Select polyline to alter to B-spline: "
"Select B-spline to decurve: "
"No entity selected!"
"No polyline selected!"
"Number of segments for approximation (2 to 1024)"
"Number for appoximation must be greater than 1!\n"
"Number for appoximation must be less than 1024!\n"
))
(if FLX_XLANGUAGE (FLX_XLANGUAGE "_spln" "_spline"))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(if POLY2BSPLINE
(setq tmp T)
(if (setq tmp (findfile (setq fn (strcat FLX$DIRECTORY "fl_stup.dll"))))
(XLOAD tmp)
(ALERT
(strcat (nth 0 prt_list) fn) ;@File not found: \n
(nth 1 prt_list) ;@Alert
"EXCLAMATION"
)
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(if tmp (progn
(setq tmp nil)
(initget 256 (nth 2 prt_list)) ;@Decurve
(setq e1 (entsel (nth 3 prt_list))) ;@Select polyline to alter to B-spline:
(if (eq (type e1) 'STR)
(if (or (= (substr e1 1 1) (substr (nth 2 prt_list) 1 1) )
(= (substr e1 1 2) (strcat "_" (substr (nth 2 prt_list) 1 1)) )
)
(progn ;@Decurve
(setq e1 nil)
(setq e2 (entsel (nth 4 prt_list))) ;@Select B-spline to decurve:
)
)
)
(if (or e1 e2)
(princ)
(princ (nth 5 prt_list)) ;@No entity selected!
)
(if (and e2 (= (type (car e2)) 'ENAME))
(if (= (cdr (assoc 0 (entget (car e2)))) "POLYLINE") ;;;### type
(BSPLINE2POLY (car e2))
(princ (nth 6 prt_list)) ;@No polyline selected!
)
)
(if (and e1 (= (type (car e1)) 'ENAME))
(if (= (cdr (assoc 0 (entget (car e1)))) "POLYLINE")
(progn
(if (not FLX$SPLINESEGMENTS) (setq FLX$SPLINESEGMENTS 8))
(setq i1 1)
(while (< i1 2)
(initget (+ 2 4 256) "8")
(setq i1 (getint (strcat
(nth 7 prt_list) ;@Number of segments for approximation (2 to 1024)"
" <"
(itoa FLX$SPLINESEGMENTS)
">: "
)))
(cond
((not i1)
(setq i1 FLX$SPLINESEGMENTS)
)
((= i1 "8")
(setq i1 8)
)
((= i1 1)
(princ
(nth 8 prt_list) ;@Number for appoximation must be greater than 1!\n
)
)
((> i1 1024)
(princ
(nth 9 prt_list) ;@Number for appoximation must be less than 1024!\n
)
(setq i1 1)
)
) ; cond
) ; while
(setq FLX$SPLINESEGMENTS i1)
(POLY2BSPLINE (car e1) FLX$SPLINESEGMENTS)
)
(princ (nth 6 prt_list)) ;@No polyline selected!
)
)
))
(if fn (XUNLOAD fn))
(setq *error* nil)
(princ)
)
(princ)
;;; ================================================================
;;; PCURVE
(defun FLX_PCURVE ( / prt_list tmp fn e1 e2 i1)
(defun *ERROR* (msg / msg)
(if (or (= msg "User break")
(= msg "Abbruch durch den Nutzer")
)
(princ)
(princ msg)
)
(setq *error* nil)
(if fn (XUNLOAD fn))
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(setq prt_list (list
"File not found: \n" ;0
"Alert" ;1
"Decurve" ;2
"Select 2D-polyline to alter to curved polyline: " ;3
"Select curved polyline to decurve: " ;4
"No entity selected!" ;5
"No polyline selected!" ;6
"Number of steps for interpolation points (0...6)" ;7
"Number of steps must be between 0 through 6!\n" ;8
"Tension (0.0 ... 1.0)" ;9
"Value for tension must be between 0.0 and 1.0!\n" ;10
"No polyline selected!" ;11
"3D polyline or 3D mesh can not be altered to curved polyline!" ;12
))
(if FLX_XLANGUAGE (FLX_XLANGUAGE "_spln" "_pcurve"))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(if POLY2CATROM_2D
(setq tmp T)
(if (setq tmp (findfile (setq fn (strcat FLX$DIRECTORY "fl_stup.dll"))))
(XLOAD tmp)
(ALERT
(strcat (nth 0 prt_list) fn) ;@File not found: \n
(nth 1 prt_list) ;@Alert
"EXCLAMATION"
)
)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(if tmp (progn
(setq tmp nil)
(initget 256 (nth 2 prt_list)) ;@Decurve
(setq e1 (entsel (nth 3 prt_list))) ;@Select 2D-polyline to alter to curved polyline:
(if (eq (type e1) 'STR)
(if (or (= (substr e1 1 1) (substr (nth 2 prt_list) 1 1) )
(= (substr e1 1 2) (strcat "_" (substr (nth 2 prt_list) 1 1)) )
)
(progn ;;;Decurve
(setq e1 nil)
(setq e2 (entsel (nth 4 prt_list))) ;@Select curved polyline to decurve:
)
)
)
(if (or e1 e2)
(princ)
(princ (nth 5 prt_list)) ;@No entity selected!
)
(if (and e2 (= (type (car e2)) 'ENAME))
(if (= (cdr (assoc 0 (entget (car e2)))) "POLYLINE") ;;;### type
(CATROM2POLY_2D (car e2))
(princ (nth 6 prt_list)) ;@No polyline selected!
)
)
(if (and e1 (= (type (car e1)) 'ENAME))
(if (= (cdr (assoc 0 (entget (car e1)))) "POLYLINE")
(progn
(if (not FLX$PCURVESTEPS) (setq FLX$PCURVESTEPS 3))
(setq i1 -1)
(while (< i1 0)
(initget (+ 4 256) "3")
(setq i1 (getint (strcat
(nth 7 prt_list) ;@Number of steps for interpolation points (0 ... 6)
" <"
(itoa FLX$PCURVESTEPS)
">: "
)))
(cond
((not i1)
(setq i1 FLX$PCURVESTEPS)
)
((= i1 "3")
(setq i1 3)
)
((or (< i1 0)(> i1 6))
(princ
(nth 8 prt_list) ;@Number of steps must be between 0 through 6!\n
)
)
) ; cond
) ; while
(setq FLX$PCURVESTEPS i1)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Get value for tension
(if (not FLX$PCURVETENSION) (setq FLX$PCURVETENSION 0.5))
(setq i1 -1)
(while (< i1 0.00)
(initget (+ 2 256) "0.5")
(setq i1 (getreal (strcat
(nth 9 prt_list) ;@Tension (0.0 ... 1.0)
" <"
(rtos FLX$PCURVETENSION 2)
">: "
)))
(cond
((not i1)
(setq i1 FLX$PCURVETENSION)
)
((= i1 "0.5")
(setq i1 0.5)
)
((or (< i1 0.00)(> i1 1.00))
(princ
(nth 10 prt_list) ;@Value for tension must be between 0.0 and 1.0!\n
)
)
) ; cond
) ; while
(setq FLX$PCURVETENSION i1)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Create catmull-rom curve
(if (null (POLY2CATROM_2D (car e1) FLX$PCURVESTEPS FLX$PCURVETENSION))
(princ (nth 12 prt_list)) ;;;@3D polyline or 3D mesh can not be altered to curved polyline!
)
)
(princ (nth 11 prt_list)) ;@No polyline selected!
)
)
))
(if fn (XUNLOAD fn))
(setq *error* nil)
(princ)
)
(princ)