- UID
- 525
- 积分
- 3148
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-14
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
可分类统计多曲线长度的程序
[php]
;;;---------------------------------------------------------------------------;
;;;
;;; bomlenghts.lsp
;;;
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2004 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;;
;;; 1998-03-31 - First release
;;; 2000-05-11 - Fixed for LWPOLYLINES and for A2k
;;; 2003-06-10 - Tested on 2004 and fixed a minor bug
;;; 2004-03-18 - Added (vl-load-com)
;;; Tested on AutoCAD 2000, 2004, 2005
;;; should be working on older versions too with minor modifications.
;;; exchange bom-code-old with bom-code
;;;;;;---------------------------------------------------------------------------;
;;; DESCRIPTION
;;;
;;; BILL OF LENGHTS.
;;; c:bomlengths - lenght of lines, arcs, polylines and splines and total.
;;; c:bom_lines - lenght of lines and total.
;;; c:bom_arcs - lenght of arcs, and total.
;;; c:bom_polylines - lenght of polylines and total.
;;; c:bom_splines - lenght of splines and total.
;;;---------------------------------------------------------------------------;
(defun dxf (n ed) (cdr (assoc n ed)))
(defun bom-code (ssfilter / errexit undox restore
*error* olderr oldcmdecho %l %t
sset %i en ed p1 p2
ot a1 a2 r
)
(defun errexit (s)
(princ)
(restore)
)
(defun undox ()
(command "._undo" "_E")
(setvar "cmdecho" oldcmdecho)
(setq *error* olderr)
(princ)
)
(setq olderr *error*
restore undox
*error* errexit
)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "._UNDO" "_BE")
(setq %i 0
%t 0
)
(vl-load-com)
(setq sset (ssget ssfilter))
(if sset
(progn
(princ "\nLengths:")
(repeat (sslength sset)
(setq en (ssname sset %i))
(setq ed (entget en))
(setq ot (dxf 0 ed))
(setq curve (vlax-ename->vla-object en))
(if (vl-catch-all-error-p
(setq len (vl-catch-all-apply
'vlax-curve-getDistAtParam
(list curve
(vl-catch-all-apply
'vlax-curve-getEndParam
(list curve)
)
)
)
)
)
nil
len
)
(setq %l len)
(setq %i (1+ %i)
%t (+ %l %t)
)
(terpri)
(princ %l)
)
(princ "\nTotal = ")
(princ %t)
(textpage)
)
)
(restore)
)
(defun bom-code-old (ssfilter / errexit undox restore
*error* olderr oldcmdecho %l %t
sset %i en ed p1 p2
ot a1 a2 r
)
(defun errexit (s)
(princ)
(restore)
)
(defun undox ()
(command "._undo" "_E")
(setvar "cmdecho" oldcmdecho)
(setq *error* olderr)
(princ)
)
(setq olderr *error*
restore undox
*error* errexit
)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "._UNDO" "_BE")
(setq %i 0
%t 0
)
(setq sset (ssget ssfilter))
(if sset
(progn
(princ "\nLengths:")
(repeat (sslength sset)
(setq en (ssname sset %i))
(setq ed (entget en))
(setq ot (dxf 0 ed))
(cond
((= ot "LINE")
(setq p1 (dxf 10 ed)
p2 (dxf 11 ed)
%l (distance p1 p2)
)
)
((= ot "ARC")
(setq a1 (dxf 50 ed)
a2 (dxf 51 ed)
r (dxf 40 ed)
%l (* r (abs (- a2 a1)))
)
)
(t
(command "._area" "_obj" en)
(setq %l (getvar "perimeter"))
)
)
(setq %i (1+ %i)
%t (+ %l %t)
)
(terpri)
(princ %l)
)
(princ "\nTotal = ")
(princ %t)
(textpage)
)
)
(restore)
)
(defun c:test ()
(initget "Lines Arcs Polylines Splines ALL")
(setq ans (getkword
"Enter an option [Lines/Arcs/Polylines/Splines] <ALL>: "
)
)
(cond
((= ans "Lines") (c:bom_lines))
((= ans "Arcs") (c:bom_arcs))
((= ans "Polylines") (c:bom_polylines))
((= ans "Splines") (c:bom_splines))
(t
(bom-code '((-4 . "<OR")
(0 . "LINE")
(0 . "ARC")
(0 . "POLYLINE")
(0 . "LWPOLYLINE")
(0 . "SPLINE")
(-4 . "OR>")
)
)
)
)
(princ)
)
(defun c:bom_lines ()
(bom-code '((0 . "LINE")))
(princ)
)
(defun c:bom_arcs ()
(bom-code '((0 . "ARC")))
(princ)
)
(defun c:bom_polylines ()
(bom-code '((-4 . "<OR")
(0 . "POLYLINE")
(0 . "LWPOLYLINE")
(-4 . "OR>")
)
)
(princ)
)
(defun c:bom_splines ()
(bom-code '((0 . "SPLINE")))
(princ)
)
[/php] |
|