Handling in vla-get-area
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 Nothing is wrong with the code , unless you have this is a part of another routine 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. 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)) ) ) )) 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. 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)) I need to do some tests and I'll be back.
Thanks to all!
页:
[1]