土木在线论坛 \ 道路桥梁 \ 铁路工程 \ LISP计算选定对象的总面积

LISP计算选定对象的总面积

发布于:2008-11-01 00:31:01 来自:道路桥梁/铁路工程 [复制转发]
不会用LISP的请看说明,此程序功能计算选定区域的面积
LISP使用,把下面代码复制到记事本中保存为×.lsp,然后放在CAD的support文件夹中,最后打开CAD,工具---加载,选中刚才的文件即可
程序使用快捷键:aream[code];;; AREAM.LSP
;;; Function: Calculates the total area of selected objects
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2002 JTB World, All Rights Reserved
;;; Website:www.jtbworld.com / http://jtbworld.vze.com
;;; E-mail: info@jtbworld.com / jtbworld@hotmail.com
;;; Tested on AutoCAD 2000

(defun c:aream (/ olderr oldcmdecho errexit undox restore ss1 nr en tot_area)
(defun errexit (s)
(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")
(if (setq ss1 (ssget '((-4 . "
(0 . "POLYLINE")
(0 . "LWPOLYLINE")
(0 . "CIRCLE")
(0 . "ELLIPSE")
(0 . "SPLINE")
(0 . "REGION")
(-4 . "OR>")
)
)
)
(progn
(setq nr 0)
(setq tot_area 0.0)
(setq en (ssname ss1 nr))
(while en
(command "._area" "_O" en)
(setq tot_area (+ tot_area (getvar "area")))
(setq nr (1+ nr))
(setq en (ssname ss1 nr))
)
(princ "\nTotal Area = ")
(princ tot_area)
)
)
(restore)
)[/code]文章来自:路桥隧网( http://xingyou.5d6d.com) 详细出处请参考: http://xingyou.5d6d.com/thread-813-1-1.html
这个家伙什么也没有留下。。。

铁路工程

返回版块

6.76 万条内容 · 125 人订阅

猜你喜欢

阅读下一篇

谢谢啦

非常感谢!!!!!!!!!!!!!!!

回帖成功

经验值 +10