明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1645|回复: 1

[LISP]怎样求实体的型心?

[复制链接]
发表于 2006-4-23 11:56:00 | 显示全部楼层 |阅读模式
怎样求实体的型心?
发表于 2006-4-23 16:04:00 | 显示全部楼层
  1. (load "xyp_lib.vlx")  ;版本 V.20060422
  2. ;|下载和加载通用函数(可在签名栏直接下载后放到搜索路径下)
  3. 利用以下任何一种方式(首选第一种)即可加载和运行通用函数内的所有子程序:
  4. ★1·在acad.lsp中增加(load"xyp_lib.vlx")
  5. ■2·在每个程序内增加(load"xyp_lib.vlx")
  6. ■3·在command下,输入(load"xyp_lib.vlx")
  7. ■4·在菜单.mnl中增加(load"xyp_lib.vlx")
  8. ■5·将xyp_lib.vlx文件直接拽到cad屏幕
  9. [COLOR=red] ★通用函数下载地址:[/COLOR]
  10. [url]http://www.xdcad.net/forum/attachment.php?s=&postid=1606661[/url]
  11. [url]http://bbs.mjtd.com/forum.php?mod=viewthread&tid=37554[/url]
  12. [url]http://free.ys168.com/?xyp1964[/url]
  13. |;
  14. ;;;封闭域的形心、惯性矩、惯性积、旋转半径
  15. (defun c:test285 ()
  16.   (defun write-tmp ()
  17.     (setq f (open "c:/tmp.mpr" "r"))
  18.     (read-line f)
  19.     (read-line f)
  20.     (read-line f)
  21.     (while (setq txt (read-line f))
  22.       (setq pt (list (car pt) (- (cadr pt) (* sc 800))))
  23.       (xyp-Text 1 pt txt)
  24.     )
  25.     (close f)
  26.   )
  27.   (cmdlasc0)
  28.   (setvar "osmode" 0)
  29.   (xyp-mkLaCo "中心线" 1)
  30.   (while (setq pt (getpoint "\n选择区域内一点<退出> : "))
  31.     (command "-boundary" "a" "o" "r" "" pt "")
  32.     (setq s1 (entlast)
  33.    pt (vlax-safearray->list
  34.         (vlax-variant-value
  35.    (vla-get-centroid (xyp-Ve2Vo s1))
  36.         )
  37.       )
  38.     )
  39.     (xyp-Cross pt (* sc 200) 1)
  40.     (command "MASSPROP" s1 "" "y" "c:/tmp.mpr")
  41.     (xyp-mkLaCo "面域标注" 4)
  42.     (write-tmp)
  43.     (redraw)
  44.   )
  45.   (cmdla1)
  46. )
  47. ;|
  48. 相关vl函数:
  49. AutoLISP 对象名 : (setq s1 (car(entsel)))
  50. VL实体 : (setq Object (xyp-Ve2Vo s1))
  51. 面积 : (vla-get-Area (xyp-Ve2Vo s1))
  52. 周长 : (vla-get-Perimeter (xyp-Ve2Vo s1))
  53. 边界框 : (xyp-get-MinMaxPoint s1 1)
  54.          (xyp-get-MinMaxPoint s1 9)
  55. 质心 : (vlax-safearray->list
  56.         (vlax-variant-value
  57.    (vla-get-Centroid (xyp-Ve2Vo s1))
  58.         )
  59.       )
  60. 惯性矩 : (vlax-safearray->list
  61.         (vlax-variant-value
  62.    (vla-get-MomentOfInertia (xyp-Ve2Vo s1))
  63.         )
  64.       )
  65. 惯性积 : (vla-get-ProductOfInertia (xyp-Ve2Vo s1))
  66. 旋转半径 : (vlax-safearray->list
  67.         (vlax-variant-value
  68.    (vla-get-RadiiOfGyration (xyp-Ve2Vo s1))
  69.         )
  70.       )
  71. 主力矩与质心的 X-Y 方向 : (vlax-safearray->list
  72.         (vlax-variant-value
  73.    (vla-get-PrincipalMoments (xyp-Ve2Vo s1))
  74.         )
  75.       )
  76. |;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-9-20 01:40 , Processed in 0.175152 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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