
I vas unable to make it perfect; there are small geometrical errors at the joint of the different segments. Save your work before to start this routine, especially if you asked for a very smooth solid!
On computers with limited resources, you may (try) to increase the speed:
- set the SHADEMODE to 2D wireframe
- use the PLAN command before you start
- don’t zoom/pan during the lisp works
Code:
; Draw a solid curved cone
; mfuccaro@hotmail.com
; _____________ Apr. 2004 ____
;
(defun c:CUCONE(/ arc arc_cen arc_rad arc_ang1 arc_ang2 ang0
r1 r2 r0 r rr ; radiuses for the cross_section
ct pts a b o_snap solid
p p1 p2
xmin xmax ymin ymax zmin zmax ;bounding box
k i j) ;Used as index
(setvar "cmdecho" 0)
(command "undo" "begin")
(setq arc (entget (car (entsel "\nselect arc ")))
arc_cen (cdr (assoc 10 arc))
arc_rad (cdr (assoc 40 arc))
arc_ang1 (cdr (assoc 50 arc))
arc_ang2 (cdr (assoc 51 arc))
ang0 (/ (- arc_ang2 arc_ang1) (getvar "surftab1"))
r1 (getdist " end radius ")
r2 (getdist " start radius ")
r0 (/ (- r2 r1) (* 1.0 (getvar "surftab1"))))
(if (<= (* r1 r2) 0) (progn
(alert "radius must be positive, non zero!")
(quit)))
(setq ct (cons (+ arc_rad (car arc_cen)) (cdr arc_cen))
pts nil
r (- r1 r0)
a (- arc_ang1 ang0)
b (/ (* 2 pi) (getvar "surftab2"))
o_snap (getvar "osmode")
solid (ssadd))
(repeat (1+ (getvar "surftab1"))
(setq i 0
r (+ r r0)
a (+ a ang0))
(repeat (1+ (getvar "surftab2"))
(setq p (polar ct (- (/ PI 2) (* (setq i (1+ i)) b)) r)
p1 (list (car p) (cadr ct) (+ (caddr ct) (- (cadr p) (cadr ct))))
rr (- (car p1) (car arc_cen))
p2 (list (+ (car arc_cen) (* rr (cos a)))
(+ (cadr arc_cen) (* rr (sin a)))
(caddr p1))
pts (cons p2 pts)))
(setq pts (cons (polar arc_cen a arc_rad) pts))
)
(setq xmin (apply 'min (mapcar 'car pts))
xmax (apply 'max (mapcar 'car pts))
ymin (apply 'min (mapcar 'cadr pts))
ymax (apply 'max (mapcar 'cadr pts))
zmin (apply 'min (mapcar 'caddr pts))
zmax (apply 'max (mapcar 'caddr pts)))
(command "zoom" "w" (list xmin ymin) (list xmax ymax))
(setq i 0)
(repeat (getvar "surftab1")
(setq j (+ i 2 (getvar "surftab2")) k 1)
(command "box" (list xmin ymin zmin) (list xmax ymax zmax))
(command "slice" "l" "" arc_cen (nth (1+ i) pts) (nth (+ i 2) pts) (nth j pts))
(command "slice" "l" "" arc_cen (nth (1+ j) pts) (nth (+ j 2) pts) (nth i pts))
(repeat (getvar "surftab2")
(if (< k (/ (getvar "surftab2") 2))
(progn
(command "slice" "l" "" (nth (+ i k) pts) (nth (+ j k) pts) (nth (+ j k 1) pts) (nth j pts))
(command "slice" "l" "" (nth (+ j k 1) pts) (nth (+ i k 1) pts) (nth (+ i k) pts) (nth i pts))
)
(progn
(command "slice" "l" "" (nth (+ i k) pts) (nth (+ j k) pts) (nth (+ i k 1) pts) (nth j pts))
(command "slice" "l" "" (nth (+ j k 1) pts) (nth (+ i k 1) pts) (nth (+ j k) pts) (nth i pts))
))
(setq k (1+ k))
(ssadd (entlast) solid)
)
(setq i j))
(command "union" solid "")
(command "zoom" "P")
(setvar "osmode" o_snap)
(princ "\nTo change the smotness: delete the cone, adjust SURFTAB1 and/or SURFTAB2, than run again")
(command "undo" "end")
(princ)
)
(progn
(princ "Program loaded. Type \"CUCONE\" at the command prompt")
(princ)
)
Bookmarks