乐筑天下

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

[编程交流] Handling in vla-get-area

[复制链接]

57

主题

183

帖子

126

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
285
发表于 2022-7-6 06:20:25 | 显示全部楼层 |阅读模式
In this code
 
  1. (setq valor_area 0.0000)(setq sel (ssget "_x" (list '(0 . "HATCH")(cons 8 layer))))(if (/= sel nil)  (progn  (setq i 0)  (repeat (sslength sel)      (setq entbh (ssname sel i))      (if (/= entbh nil)         (progn              (setq lentbh (entget entbh))           (setq layerbh (cdr(assoc 8 lentbh)))           (setq valor_area(+ valor_area (vla-get-area (vlax-ename->vla-object entbh)))))))
 
 
The error is in this line
  1. (setq valor_area(+ valor_area (vla-get-area (vlax-ename->vla-object entbh))))
 
 
I received the Automation error,  how to handling this problem ?
I need that when the error occurs and the system to zoom in on the problem with hatch.
 
Thanks
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 06:31:42 | 显示全部楼层
Nothing is wrong with the code , unless you have this is a part of another routine
回复

使用道具 举报

57

主题

183

帖子

126

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
285
发表于 2022-7-6 06:44:40 | 显示全部楼层
Tharwat ,
 
I could help to create a handling for this part of the code
 
  1. vla-get-area (vlax-ename-> vla-object entbh)

 
If a problem arises you need to zoom in on the hatch and stop the process.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 06:53:54 | 显示全部楼层
Try it this way ..
 
  1. (setq valor_area 0.0)(if (setq sel (ssget "_x" (list '(0 . "HATCH") (cons 8 layer)))) (repeat (setq i (sslength sel))   (setq entbh (ssname sel (setq i (1- i))))   (setq valor_area          (+ valor_area             (vla-get-area (vlax-ename->vla-object entbh))          )   ) ))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:09:09 | 显示全部楼层
The ActiveX area property will not be available for Hatch objects with a self-intersecting boundary - this is likely causing the error you are experiencing.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 07:17:24 | 显示全部楼层
Here is one way to bypass the issue:
  1. (defun c:harea ( / a i j r s )   (setq r 0.0 j 0)   (if (setq s (ssget "_X" '((0 . "HATCH"))))       (repeat (setq i (sslength s))           (if               (vl-catch-all-error-p                   (setq a                       (vl-catch-all-apply 'vla-get-area                           (list (vlax-ename->vla-object (ssname s (setq i (1- i)))))                       )                   )               )               (setq j (1+ j))               (setq r (+ r a))           )       )   )   (if (< 0.0 r)       (princ (strcat "\nTotal Area: " (rtos r 2)))   )   (if (< 0 j)       (princ (strcat "\n" (itoa j) " had a self-intersecting boundary."))   )   (princ))
回复

使用道具 举报

57

主题

183

帖子

126

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
285
发表于 2022-7-6 07:28:43 | 显示全部楼层
I need to do some tests and I'll be back.
 
Thanks to all!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 18:43 , Processed in 0.546002 second(s), 66 queries .

© 2020-2025 乐筑天下

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