找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 681|回复: 2

[LISP程序]:推荐-螺旋线程序

[复制链接]
发表于 2006-3-15 22:26:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
;;; 3DSPIRAL.LSP
;     Copyright (C) 1992 by Autodesk, Inc.
;
;     Permission to use, copy, modify, and distribute this software
;     for any purpose and without fee is hereby granted, provided
;     that the above copyright notice appears in all copies and that
;     both that copyright notice and this permission notice appear in
;     all supporting documentation.
;
;     THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;     WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;     PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;; --------------------------------------------------------------------------;
;;; DESCRIPTION
;;;
;;;   This is a programming example.
;;;
;;;   Designed and implemented by Kelvin R. Throop in January 1985
;;;
;;;   This program constructs a spiral. It can be loaded and called
;;;   by typing either "spiral", "3dspiral" or the following:
;;;   (cspiral <# rotations> <base point> <horiz growth per rotation>
;;;            <points per circle> <start radius>
;;;            <vert growth per rotation>).
;;;
;;; --------------------------------------------------------------------------;

(defun myerror (s)                    ; If an error (such as CTRL-C) occurs
                                      ; while this command is active...
  (if (/= s "Function cancelled")
    (princ (strcat "\nError: " s))
  )
  (setvar "cmdecho" ocmd)             ; Restore saved modes
  (setvar "blipmode" oblp)
  (setq *error* olderr)               ; Restore old *error* handler
  (princ)
)

(defun cspiral (ntimes bpoint hfac lppass strad vfac
                / ang dist tp ainc dhinc dvinc circle dv)

  (setvar "blipmode" 0)               ; turn blipmode off
  (setvar "cmdecho" 0)                ; turn cmdecho off
  (setq circle (* 3.141596235 2))
  (setq ainc (/ circle lppass))
  (setq dhinc (/ hfac lppass))
  (if vfac (setq dvinc (/ vfac lppass)))
  (setq ang 0.0)
  (if vfac
    (setq dist strad dv 0.0)
    (setq dist 0.0)
  )
  (if vfac
    (command "3dpoly")                ; start spiral ...
    (command "pline" bpoint)          ; start spiral from base point and...
  )
  (repeat ntimes
    (repeat lppass
      (setq tp (polar bpoint (setq ang (+ ang ainc))
                      (setq dist (+ dist dhinc))
               )
      )
      (if vfac
          (setq tp (list (car tp) (cadr tp) (+ dv (caddr tp)))
                dv (+ dv dvinc)
          )
      )
      (command tp)                    ; continue to the next point...
    )
  )
  (command "")                        ; until done.
  (princ)
)

;;;
;;;       Interactive spiral generation
;;;

(defun C:SPIRAL (/ olderr ocmd oblp nt bp cf lp)
  ;;;;(setq olderr  *error*
  ;;;;      *error* myerror)
  (setq ocmd (getvar "cmdecho"))
  (setq oblp (getvar "blipmode"))
  (setvar "cmdecho" 0)
  (initget 1)                         ; bp must not be null
  (setq bp (getpoint "\n指定圆心: "))
  (initget 7)                         ; nt must not be zero, neg, or null
  (setq nt (getint "\n旋转圈数: "))
  (initget 3)                         ; cf must not be zero, or null
  (setq cf (getdist "\nGrowth per rotation: "))
  (initget 6)                         ; lp must not be zero or neg
  (setq lp (getint "\n每圈线段数 <360>: "))
  (cond ((null lp) (setq lp 360)))
  (cspiral nt bp cf lp nil nil)
  (setvar "cmdecho" ocmd)
  (setvar "blipmode" oblp)
  (setq *error* olderr)               ; Restore old *error* handler
  (princ)

)

;;;
;;;       Interactive spiral generation
;;;

(defun C:3DSPIRAL (/ olderr ocmd oblp nt bp hg vg sr lp)
  ;;;;(setq olderr  *error*
  ;;;;      *error* myerror)
  (setq ocmd (getvar "cmdecho"))
  (setq oblp (getvar "blipmode"))
  (setvar "cmdecho" 0)
  (initget 1)                         ; bp must not be null
  (setq bp (getpoint "\n指定圆心: "))
  (initget 7)                         ; nt must not be zero, neg, or null
  (setq nt (getint "\n旋转圈数: "))
  (initget 7)                         ; sr must not be zero, neg, or null
  (setq sr (getdist bp "\n开始的半径: "))
  (initget 1)                         ; cf must not be zero, or null
  (setq hg (getdist "\n每圈半径增大: "))
  (initget 3)                         ; cf must not be zero, or null
  (setq vg (getdist "\n每圈高度增加: "))
  (initget 6)                         ; lp must not be zero or neg
  (setq lp (getint "\n每圈线段数 <360>: "))
  (cond ((null lp) (setq lp 360)))
  (cspiral nt bp hg lp sr vg)
  (setvar "cmdecho" ocmd)
  (setvar "blipmode" oblp)
  (setq *error* olderr)               ; Restore old *error* handler
  (princ)

)

;;; --------------------------------------------------------------------------;
(princ "\n\tC:SPIRAL and C:3DSPIRAL loaded. ")
(princ)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2006-3-15 22:43:31 | 显示全部楼层
好。。谢谢。我试试看。。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2006-9-7 20:40:41 | 显示全部楼层
如何安装与使用,帮帮忙。谢谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-21 04:35 , Processed in 0.187451 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表