gzcsun 发表于 2025-1-22 17:52:20

自贡黄明儒 发表于 2025-1-22 07:57
似乎alisp只能用(command "AREA" "e" e)求面积,autocad2000之后有了com,用vla-get-area就可以求得面积

autocad2000已经是上世纪的cad了,alisp在2000年更新过,很多alisp用不了很正常。

ocoipw 发表于 2025-1-22 19:34:27

yanshengjiang 发表于 2025-1-22 15:03
前辈你好    这样看起来在ssget的时候就能过滤

;;你说得有道理,根据你的建议将程序修改如下:

;;计算各种表面、面域的面积和。设计 何勇
;;注意:绘图单位以毫米计。
(defun C:calmj(/ ss e ent)
(setq SS (ssget '((0 . "SPLINE,circle,ELLIPSE,LWPOLYLINE,POLYLINE,REGION,LOFTEDSURFACE,SURFACE,REVOLVEDSURFACE,EXTRUDEDSURFACE,PLANESURFACE,SWEPTSURFACE"))))
(setq are1 0)
(while ss
    (setq
      e (ssname ss 0)
      ent (entget e)
      ss (if (> (sslength ss) 1)
             (ssdel e ss)
          nil
         )
    )
    (command "AREA" "e" e)
    (setq are1 (+ are1 (getvar "AREA")))
);;end while
(princ (strcat "\n总面积为:" (rtos are1) "mm2"))
(princ (strcat "\n总面积为:" (rtos (/ are1 1000000.0)) "m2"))
(prin1)
)

;;欢迎各位朋友批评指正

ocoipw 发表于 2025-1-22 19:46:47

xyp1964 发表于 2025-1-22 09:29


你的代码更简洁但应增加“ELLIPSE”

muai2010 发表于 2025-1-23 12:33:51

不错,有新的思路
页: 1 [2]
查看完整版本: 面积求和