AutoLISP 绘制三维螺旋楼梯.doc_第1页
AutoLISP 绘制三维螺旋楼梯.doc_第2页
AutoLISP 绘制三维螺旋楼梯.doc_第3页
AutoLISP 绘制三维螺旋楼梯.doc_第4页
AutoLISP 绘制三维螺旋楼梯.doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

AutoLISP绘制三维螺旋楼梯一、说明本例程能够绘制建筑中的三维螺旋楼梯。根据指定的参数:圆心点、梯级高、最窄梯级宽、楼梯宽度、扶手高、底板厚度和层高,程序将自动计算并绘制出以3dface和tabsurf组成的三维螺旋楼梯模型。程序能在R12至R14版的AutoCAD中运行。二、安装将程序代码一节的文本裁剪下来,保存成名为3DSP.LSP的文本文件;将这个文件拷贝到AutoCAD的系统目录中。三、使用在AutoCAD命令行键入:(load 3dsp)然后执行:3dsp,按程序中的提示操作即可。(程序中的提示已改为中文,若需要英文提示可自行修改提示字符串或跟我联系)四、程序代码;begain 3dsp.lsp(defun dtr (r)(* r (/ pi 180.0)(defun rtd (r)(* r (/ 180.0 pi)(defun 3dsp_err (s)(if (not (member s (list console breakFunction cancelledquit/exit abort)(princ (strcat n3DSP Error: s)(if cmd (setvar cmdecho cmd)(if bli (setvar blipmode bli)(if cla (setvar clayer cla)(if os1 (setvar osmode os1)(princ)(defun spinfo (/ ht) ; staircase parameter(setq cp (getpoint n螺旋梯圆心点: )lp (getpoint cp n首级内圆起始点: )riser (getdist n梯级高: )step (getdist n内圆最窄梯级宽: )wide (getdist n楼梯宽度: )hrl (getdist n扶手高: )thi (getdist n底板厚度: )ht (getdist n层高: )case (fix (/ ht riser)riser (/ ht case)ls (sqrt (+ (expt riser 2) (expt step 2)a (/ riser ls) ; sin Ab (/ step ls) ; cos Ac lp); end SPINFO(defun spcalc (/ os1)(setq os1 (getvar osmode)(initget L R B N)(setq ans (getkword n选择扶手(L)左/(R)右/(B)双边/(N)无: )(if (not ans)(setq ans N)(setq blksp (open blksp.lst r)(if (not (equal blksp nil)(setq blk (read-line blksp)(if (equal blk nil)(setq blk sp1)(setq blk (strcat sp(itoa (1+ (atoi (substr blk 3)(setq r (distance cp lp)(setq ang (/ step r) ; determines the angle of the step(setq ac (angle cp lp)(setq rp (polar lp ac wide)lp1 (list (car lp) (cadr lp) riser)lp4 (list (car rp) (cadr rp) riser)count 0el riseral ang)(setq diag (+ ac ang)(setq lp2 (list (car (polar cp diag r)(cadr (polar cp diag r)riser)lp3 (list (car (polar cp diag (+ r wide)(cadr (polar cp diag (+ r wide)riser)lh (polar cp (+ ac (/ ang 2) (+ r (/ wide 15) ; left bottom hrllh1 (list (car lh) (cadr lh) (+ (caddr lh) riser)lh2 (list (car lh1) (cadr lh1) (+ (caddr lh1) hrl); left top hrlsht (polar cp diag (+ r (/ wide 15)shb (polar cp ac (+ r (/ wide 15)sh1 (list (car shb) (cadr shb) (+ (caddr shb) (+ hrl (/ riser 2)sh2 (list (car sht) (cadr sht) (+ (caddr sht) hrl (* riser 1.5)(setq tlp (list (car lp) (cadr lp) (- (caddr lp) (/ thi b)tl1 (list (car lp2) (cadr lp2) (- (caddr lp2) (/ thi b)trp (list (car rp) (cadr rp) (- (caddr rp) (/ thi b)tr1 (list (car lp3) (cadr lp3) (- (caddr lp3) (/ thi b)(command layer m spiral ; set spiral layer and colorlayer c blue )(setvar osmode 0)(command 3dface lp1 i lp2 lp3 lp4 ; draw the step3dface lp lp1 lp4 rp ; draw the riser3dface lp3 lp4 i rp ; draw the right side face3dface lp2 lp1 i lp ; draw the left side face3dface i trp i rp i lp3 tr1 ; draw the thickness3dface i tlp i lp i lp2 tl1 3dface i trp tlp i tl1 tr1 ); draw the bottom face(command layer m scolumn ; set handrail column layerlayer c cyan ; and colorlayer m shandrail ; set handrail layer andlayer c red ) ; and color(if (or (= ans L) (= ans B)(progn(command layer s scolumn )(command circle lh1 (/ step 18) ; draw the handrail column(setq cir (entlast)(command line lh1 lh2 )(setq lc (entlast)(command tabsurf (list cir lh1) (list lc lh1)(setq tcl (entlast)(command layer s shandrail )(command circle sh1 (/ step 15) ; draw the handrailucs y 90)(setq c1 (entlast) (setq sh1r (trans sh1 0 1)(command rotate c1 sh1r (rtd (- b)ucs )(command line sh1 sh2 )(setq l1 (entlast)(command tabsurf (list c1 sh1) (list l1 sh1)(setq thl (entlast)(if (or (= ans R)(= ans B)(progn ; draw the right handrail(setq dis (- wide (* 2 (/ wide 15)sr1 (polar sh1 ac dis)sr2 (polar sh2 diag dis)rh1 (polar lh1 (+ ac (/ ang 2) dis)rh2 (polar lh2 (+ ac (/ ang 2) dis )(command layer s scolumn )(command circle rh1 (/ step 18)(setq cir1 (entlast)(command line rh1 rh2 )(setq rc (entlast)(command tabsurf (list cir1 rh1) (list rc rh1)(setq tcr (entlast)(command layer s shandrail )(command circle sr1 (/ step 15)ucs y 90)(setq c2 (entlast) (setq sr1r (trans sr1 0 1)(command rotate c2 sr1r (rtd (- b) ucs circle sr2 (/ step 15)ucs y 90)(setq c3 (entlast) (setq sr2r (trans sr2 0 1)(command rotate c3 sr2r (rtd (- b)ucs )(command line sr1 rh2 ) (setq l2 (entlast)(command line rh2 sr2 ) (setq l3 (entlast)(command tabsurf (list c2 sr1) (list l2 sr1)tabsurf (list c3 sr2) (list l3 sr2)(setq thr (entlast)(if (= ans L)(command block blk lp c tlp lp4 tr1 tcl thl oops)(if (= ans R)(command block blk lp c tlp lp4 tr1 tcr thr oops)(if (= ans B)(command block blk lp c tlp lp4 tr1 tcl tcr thl thr oops)(if (= ans N)(command block blk lp c tlp lp4 tr1 oops)(setvar clayer cla)(setq count (1+ count) ; initialize counters for looplp (list (car (polar cp diag r)(cadr (polar cp diag r)riser)riser (+ riser el)diag (+ ang ang ac)(setvar osmode os1) ; end SPCALC(defun sbuild (/ os1)(command INSERT blk lp (rtd ang)(setq lp (list (car (polar cp diag r)(cadr (polar cp diag r)riser)count (1+ count) ; increment all countersang (+ ang al)diag (+ diag al)riser (+ riser el)(if ( count case) ; get last set of coordinates(progn ; to form ending face(setq lp2 (list (car (polar cp diag r)(cadr (polar cp diag r)riser)lp3 (list (car (polar cp diag (+ r wide)(cadr (polar cp diag (+ r wide)riser)tl1 (list (car lp2) (cadr lp2)(- (caddr lp2) (/ thi b)tr1 (list (car lp3) (cadr lp3) (- (caddr lp3) (/ thi b) ; end SBUILD(defun C:3DSP (/ bli cmd cla blksp cp lp riser step wide counthrl blk thi lp1 lp2 lp3 lp4 case el rp diag alang a tr1 tl1 os1 olderr)(setq olderr *error* *error* 3dsp_err)(setq bli (getvar blipmode)cmd (getvar cmdecho)cla (getvar clayer)(setvar blipmode 0)(setvar cmdecho 0)(setq os1 (getvar osmode os1)(setvar osmode 0)(spinfo)(spcalc)(while ( count case)(sbuild)(command layer s spiral ; draw ending face3dface i lp3 tr1 i tl1 i lp2 )(setvar cecolor bylayer)(setvar

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论