Jump to content

Recommended Posts

Posted

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

Posted

Nothing is wrong with the code , unless you have this is a part of another routine ;)

Posted

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.

Posted

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))
          )
   )
 )
)

Posted

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.

Posted

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)
)

Posted

I need to do some tests and I'll be back.

 

Thanks to all!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...