乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 37|回复: 2

[编程交流] 3D面的累积面积?

[复制链接]

5

主题

10

帖子

6

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 09:00:08 | 显示全部楼层 |阅读模式
我使用下面的lsp例程来确定单个3d人脸的面积。然而,我的“表面”是由多个3D面组成的。我不太熟悉ACAD的3D工具,但我似乎无法将人脸组合成一个曲面。。。所以,我希望累积使用上面提到的lsp例程。它是由比尔·吉利斯写的,如下所示。
 
谢谢你的帮助,
 
罗伯特
 
  1. ;| FACEAREA.lsp
  2. returns the area of a 3dface regardless of orientation or current UCS.
  3. If the point has four points which are not co-planar, returns the
  4. combined areas of the two triangular faces joined by an edge assumed
  5. to be from the 3dface's first and third corner points.
  6. Because 3Dfaces often adjoin, the desired face can be selected by any
  7. method including Window and Window Polygon, and will be highlghted to
  8. confirm selection before its area is calculated. If more than one object,
  9. a non-3Dface object, or no object is selected, the routine will exit
  10. with an error message.
  11. by Bill Gilliss
  12. bill at realerthanreal dot com
  13. Comments and suggestions always welcome.
  14. No warranty, either expressed or implied, is made as to the fitness of
  15. this information for any particular purpose.   All materials are to be
  16. considered 'as-is' and use thereof should be considered as at your own
  17. risk.
  18. v 1.0  2010-03-02 - original release in response to newsgroup request
  19. |;
  20. (defun c:faceArea.lsp ( / myerror olderror
  21.                          ss en ed p1 p2 p3 p4 area3p fArea)
  22. ;;------- subroutines --------
  23. (defun myerror (msg)
  24. (setvar 'cmdecho *cmdecho)
  25. (setq *error* olderror)
  26. )
  27. (defun area3p (p1 p2 p3 / a b c s)
  28. (setq
  29.    a (distance p1 p2)
  30.    b (distance p2 p3)
  31.    c (distance p3 p1)
  32.    s (* 0.5 (+ a b c))
  33. )
  34. (sqrt
  35.    (*
  36.        s
  37.        (- s a)
  38.        (- s b)
  39.        (- s c)
  40.    )
  41. )
  42. )
  43. ;;=========== main routine ===============
  44. (setq olderror *error*)
  45. (setq *error* myerror)
  46. (setq *cmdecho (getvar 'cmdecho)) (setvar 'cmdecho 0)
  47. (prompt "\nSelect a single 3D face: ")
  48. (command "._select" pause) ;;to be able to preview selection
  49. (setq ss (ssget "P"))
  50. (cond
  51.      ( (and (= (sslength ss) 1)
  52.             (= "3DFACE" (cdr (assoc 0 (entget (ssname ss 0)))))
  53.             )
  54.        (setq en (ssname ss 0)
  55.              ed (entget en)
  56.              p1 (cdr (assoc 10 ed))
  57.              p2 (cdr (assoc 11 ed))
  58.              p3 (cdr (assoc 12 ed))
  59.              p4 (cdr (assoc 13 ed))
  60.              )
  61.        (setq fArea (+ (area3p p1 p2 p3) (area3p p3 p4 p1)))
  62.        (princ "\nArea: ") (princ fArea) (princ)
  63.        )
  64.      ( (and (= (sslength ss) 1)
  65.              (not (= "3DFACE" (cdr (assoc 0 (entget (ssname ss 0))))))
  66.              )
  67.        (princ "Not a 3Dface.")
  68.        )
  69.       
  70.      ( (not ss)
  71.          (princ "Nothing selected.")
  72.          )
  73.          
  74.      ( (> (sslength ss) 1)
  75.        (princ "Too many objects selected.")
  76.        )
  77.      );cond
  78.      
  79. (myerror) ;; cleanup
  80. (princ)
  81. );defun
  82. (defun c:3fa ()
  83. (c:facearea)
  84. )
  85. (princ "FACEAREA loaded. Type FACEAREA or 3FA to run.")
  86. (princ)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 09:30:52 | 显示全部楼层
非常容易修复需要一个ssget“X”选择所有3dfaces过滤器(0.“3DFACE”)
 
(setq ss(ssget“X”'((0.3DFACE”)))
 
然后需要一段时间在3dfaces中循环,并继续添加面积(setq面积(+面积farea))
 
此外,(ssname ss x),其中x是用于检索每个实体的计数器,(ssdel ssname ss x))用于删除并保持循环。
 
现在有点忙,其他人可以
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 10:27:35 | 显示全部楼层
现在别忘了测试
多恩
像所有好的免责声明一样,检查结果也请添加回原始作者的详细信息
 
  1. (defun c:faceArea.lsp ( / myerror olderror
  2.                          ss en ed p1 p2 p3 p4 area3p fArea)
  3. ;;------- subroutines --------
  4. (defun area3p (p1 p2 p3 / a b c s)
  5. (setq
  6.    a (distance p1 p2)
  7.    b (distance p2 p3)
  8.    c (distance p3 p1)
  9.    s (* 0.5 (+ a b c))
  10. )
  11. (sqrt
  12.    (*
  13.        s
  14.        (- s a)
  15.        (- s b)
  16.        (- s c)
  17.    )
  18. )
  19. )
  20. ;;=========== main routine ===============
  21. (setq x 0)
  22. (setq totarea 0.0)
  23. (setq ss (ssget "X" '((0 . "3DFACE"))))
  24. (setq y  (sslength ss))  
  25.       
  26. (If   (=  ss nil)
  27. (progn
  28. (Getstring  "\nNo 3d faces . Press any key when ready ")
  29. (exit)
  30. )
  31. )
  32. (setq y  (sslength ss))  
  33. (repeat y
  34.        (setq en (ssname ss x)
  35.              ed (entget en)
  36.              p1 (cdr (assoc 10 ed))
  37.              p2 (cdr (assoc 11 ed))
  38.              p3 (cdr (assoc 12 ed))
  39.              p4 (cdr (assoc 13 ed))
  40.              )
  41.        (setq fArea (+ (area3p p1 p2 p3) (area3p p3 p4 p1)))
  42.        (setq totarea (+ totarea farea))
  43.        (princ "\nArea: ") (princ totArea) (princ)
  44.          
  45.      (setq x (+ x 1))
  46. ) ; repeat
  47. )  ;defun
  48. (defun c:3fa ()
  49. (c:facearea)
  50. )
  51. (princ "FACEAREA loaded. Type FACEAREA or 3FA to run.")
  52. (princ)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 06:01 , Processed in 0.948817 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表