rodrigo_sjc_sp Posted July 15, 2013 Posted July 15, 2013 In this code (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 (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 Quote
Tharwat Posted July 15, 2013 Posted July 15, 2013 Nothing is wrong with the code , unless you have this is a part of another routine Quote
rodrigo_sjc_sp Posted July 15, 2013 Author Posted July 15, 2013 Tharwat , I could help to create a handling for this part of the code vla-get-area (vlax-ename-> vla-object entbh) If a problem arises you need to zoom in on the hatch and stop the process. Quote
Tharwat Posted July 15, 2013 Posted July 15, 2013 Try it this way .. (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)) ) ) ) ) Quote
Lee Mac Posted July 15, 2013 Posted July 15, 2013 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. Quote
Lee Mac Posted July 15, 2013 Posted July 15, 2013 Here is one way to bypass the issue: (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) ) Quote
rodrigo_sjc_sp Posted July 15, 2013 Author Posted July 15, 2013 I need to do some tests and I'll be back. Thanks to all! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.