乐筑天下

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

[综合讨论] 计数图案填充内的对象

[复制链接]

1

主题

1

帖子

0

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 23:19:12 | 显示全部楼层 |阅读模式
如何在阴影区域内自动计数对象。是否有快速命令来执行此操作?需要帮助。
 
谢谢
奥尔金
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-7 00:04:48 | 显示全部楼层
非常简单,有一个图案填充边界选项,它在图案填充周围创建一条pline,然后使用它,你可以在多边形内执行(ssget“wp”),它将找到所有对象。现在有点忙,我会看到,
 
这是一个开始,在对象周围的pline上尝试。
  1. ; Text in polygons
  2. ; By Alan H may 2013
  3. (vl-load-com)
  4. (defun getcoords (ent)
  5. (vlax-safearray->list
  6.    (vlax-variant-value
  7.      (vlax-get-property
  8.    (vlax-ename->vla-object ent)
  9.    "Coordinates"
  10.      )
  11.    )
  12. )
  13. )
  14. (defun co-ords2xy ()
  15. ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
  16. (setq numb (/ (length co-ords) 2))
  17. (setq I 0)
  18. (repeat numb
  19. (setq xy (list (nth I co-ords)(nth (+ I 1) co-ords) ))
  20. (setq coordsxy (cons xy coordsxy))
  21. (setq I (+ I 2))
  22. ) ; end repeat
  23. ) ; end defun
  24. ; program starts here
  25. ; choose output file change acdatemp to what you want
  26. (setq fname (strcat "c:/alan/" (getstring "\nEnter file name ")))
  27. (setq fout (open fname "w"))
  28. (setq plobjs (ssget (list (cons 0 "lwpolyline"))))
  29. (setq numb1 (sslength plobjs))
  30. (setq x numb1)
  31. (repeat numb1
  32. (setq obj (ssname plobjs (setq x (- x 1))))
  33. (setq co-ords (getcoords obj))
  34. (co-ords2xy)
  35. ; write pline co-ords here
  36. (setq numb3 (length co-ords))
  37. (setq z numb3)
  38. (setq ansco-ords "")
  39. (repeat numb3
  40. (setq ansco-ords (strcat ansco-ords (rtos (nth (setq z (- z 1)) co-ords) 2 3 ) " " ))
  41. )
  42. (setq ans (strcat "Pline " ansco-ords))
  43. (write-line ans fout)
  44. (setq ansco-ords "")
  45. (setq ss (ssget "WP" coordsxy ) ; selection set  within polygon
  46. (if (= ss nil)
  47. (princ "\nnothing inside")
  48. (progn
  49. (setq coordsxy nil) ; reset for next time
  50. (setq numb2 (sslength ss))
  51. (setq y numb2)
  52. (repeat numb2
  53. (setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring"))
  54. (princ anstext) ; change to write text to file
  55. (write-line (strcat "text " anstext) fout)
  56. (princ "\n")
  57. ) ; end repeat2
  58. (setq ss nil) ; reset for next poly
  59. )
  60. )
  61. ) ; end repeat1
  62. (close fout)
  63. (princ)
回复

使用道具 举报

lrm

1

主题

257

帖子

282

银币

限制会员

铜币
-13
发表于 2022-7-7 00:45:49 | 显示全部楼层
另一种可能会为您提供所需计数但不会自动使用阴影区域的方法是发出MOVE命令,后跟WP。然后,您可以跟踪感兴趣的区域,并获得边界内找到的对象数。使用CP可以获得内部和交叉点的计数。获得计数后退出移动命令。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 10:52 , Processed in 0.610842 second(s), 58 queries .

© 2020-2025 乐筑天下

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