PDA

View Full Version : Curved Cone



fuccaro
27th Apr 2004, 01:49 pm
http://www.cadimage.net/fuccaro/cucone.jpg
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


; 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"))))
&#40;if &#40;<= &#40;* r1 r2&#41; 0&#41; &#40;progn
&#40;alert "radius must be positive, non zero!"&#41;
&#40;quit&#41;&#41;&#41;
&#40;setq ct &#40;cons &#40;+ arc_rad &#40;car arc_cen&#41;&#41; &#40;cdr arc_cen&#41;&#41;
pts nil
r &#40;- r1 r0&#41;
a &#40;- arc_ang1 ang0&#41;
b &#40;/ &#40;* 2 pi&#41; &#40;getvar "surftab2"&#41;&#41;
o_snap &#40;getvar "osmode"&#41;
solid &#40;ssadd&#41;&#41;

&#40;repeat &#40;1+ &#40;getvar "surftab1"&#41;&#41;
&#40;setq i 0
r &#40;+ r r0&#41;
a &#40;+ a ang0&#41;&#41;

&#40;repeat &#40;1+ &#40;getvar "surftab2"&#41;&#41;
&#40;setq p &#40;polar ct &#40;- &#40;/ PI 2&#41; &#40;* &#40;setq i &#40;1+ i&#41;&#41; b&#41;&#41; r&#41;
p1 &#40;list &#40;car p&#41; &#40;cadr ct&#41; &#40;+ &#40;caddr ct&#41; &#40;- &#40;cadr p&#41; &#40;cadr ct&#41;&#41;&#41;&#41;
rr &#40;- &#40;car p1&#41; &#40;car arc_cen&#41;&#41;
p2 &#40;list &#40;+ &#40;car arc_cen&#41; &#40;* rr &#40;cos a&#41;&#41;&#41;
&#40;+ &#40;cadr arc_cen&#41; &#40;* rr &#40;sin a&#41;&#41;&#41;
&#40;caddr p1&#41;&#41;
pts &#40;cons p2 pts&#41;&#41;&#41;
&#40;setq pts &#40;cons &#40;polar arc_cen a arc_rad&#41; pts&#41;&#41;
&#41;
&#40;setq xmin &#40;apply 'min &#40;mapcar 'car pts&#41;&#41;
xmax &#40;apply 'max &#40;mapcar 'car pts&#41;&#41;
ymin &#40;apply 'min &#40;mapcar 'cadr pts&#41;&#41;
ymax &#40;apply 'max &#40;mapcar 'cadr pts&#41;&#41;
zmin &#40;apply 'min &#40;mapcar 'caddr pts&#41;&#41;
zmax &#40;apply 'max &#40;mapcar 'caddr pts&#41;&#41;&#41;
&#40;command "zoom" "w" &#40;list xmin ymin&#41; &#40;list xmax ymax&#41;&#41;
&#40;setq i 0&#41;
&#40;repeat &#40;getvar "surftab1"&#41;
&#40;setq j &#40;+ i 2 &#40;getvar "surftab2"&#41;&#41; k 1&#41;
&#40;command "box" &#40;list xmin ymin zmin&#41; &#40;list xmax ymax zmax&#41;&#41;
&#40;command "slice" "l" "" arc_cen &#40;nth &#40;1+ i&#41; pts&#41; &#40;nth &#40;+ i 2&#41; pts&#41; &#40;nth j pts&#41;&#41;
&#40;command "slice" "l" "" arc_cen &#40;nth &#40;1+ j&#41; pts&#41; &#40;nth &#40;+ j 2&#41; pts&#41; &#40;nth i pts&#41;&#41;
&#40;repeat &#40;getvar "surftab2"&#41;
&#40;if &#40;< k &#40;/ &#40;getvar "surftab2"&#41; 2&#41;&#41;
&#40;progn
&#40;command "slice" "l" "" &#40;nth &#40;+ i k&#41; pts&#41; &#40;nth &#40;+ j k&#41; pts&#41; &#40;nth &#40;+ j k 1&#41; pts&#41; &#40;nth j pts&#41;&#41;
&#40;command "slice" "l" "" &#40;nth &#40;+ j k 1&#41; pts&#41; &#40;nth &#40;+ i k 1&#41; pts&#41; &#40;nth &#40;+ i k&#41; pts&#41; &#40;nth i pts&#41;&#41;
&#41;
&#40;progn
&#40;command "slice" "l" "" &#40;nth &#40;+ i k&#41; pts&#41; &#40;nth &#40;+ j k&#41; pts&#41; &#40;nth &#40;+ i k 1&#41; pts&#41; &#40;nth j pts&#41;&#41;
&#40;command "slice" "l" "" &#40;nth &#40;+ j k 1&#41; pts&#41; &#40;nth &#40;+ i k 1&#41; pts&#41; &#40;nth &#40;+ j k&#41; pts&#41; &#40;nth i pts&#41;&#41;
&#41;&#41;
&#40;setq k &#40;1+ k&#41;&#41;
&#40;ssadd &#40;entlast&#41; solid&#41;
&#41;
&#40;setq i j&#41;&#41;
&#40;command "union" solid ""&#41;
&#40;command "zoom" "P"&#41;
&#40;setvar "osmode" o_snap&#41;
&#40;princ "\nTo change the smotness&#58; delete the cone, adjust SURFTAB1 and/or SURFTAB2, than run again"&#41;
&#40;command "undo" "end"&#41;
&#40;princ&#41;
&#41;
&#40;progn
&#40;princ "Program loaded. Type \"CUCONE\" at the command prompt"&#41;
&#40;princ&#41;
&#41;

David Bethel
27th Apr 2004, 03:31 pm
fuccaro,

That looks pretty cool! I'm not much of solids kinda guy. I prefer 3dmeshes ( even with all of their short comings. )

I think that there is a command that will adjust the smothness after the solid is made. I saw it on one the NGs I read.

-David

The lisp routine is about 20KB and does some pretty wierd stuff. I've worked on it for 7 or 8 years now.

http://www.davidbethel.com/0-talkg/tubepoly.lsp

R12 DWG File
http://www.davidbethel.com/0-talkg/test.dwg

http://www.davidbethel.com/0-talkg/copia.jpg

fuccaro
28th Apr 2004, 06:09 am
Here is an image I tried to upload yesterday, but at that time CADTutor was working on the site.
http://www.cadimage.net/fuccaro/cucone1.jpg

I'm not much of solids kinda guy. I prefer 3dmeshes Solids are easy to manipulate. Can you make a hole in your 3D Mesh? :D

Peter31712
28th Apr 2004, 03:21 pm
How about if the extrude path is a 3DPoly line instead of arc segment ???

David Bethel
28th Apr 2004, 06:29 pm
Can you make a hole in your 3D Mesh?

You can but it is a royal pain!....


How about if the extrude path is a 3DPoly line instead of arc segment ???

I don't think ACAD's EXTRUDE can handle it. -David