Jump to content
gsc

How to check if (vla-boolean A acIntersection B) is True or Nil?

Recommended Posts

gsc

Hi,

 

I have a sub function which executes a (vla-boolean A acIntersection B) command for 2 Regions.

I only want to check with this function if the 2 Region are intersecting or not (something like T or Nil)

And delete the regions afterwards (or can that be done by only checking?)

 

How do I do that?

 

(defun reg_intersect ( ss / reg_lst ent )
    (setq num 0)
    (repeat (sslength ss)
        (setq ent (ssname ss num))
        (if (= (cdr (assoc 0 (entget ent))) "REGION")
            (progn
                (setq reg_lst (cons (vlax-ename->vla-object ent) reg_lst))
            )
        )            
        (setq num (1+ num))
    )
    (vla-boolean (car reg_lst) acIntersection (cadr reg_lst))
)
;;Note: there are always 2 Regions in my selection set

 

Share this post


Link to post
Share on other sites
marko_ribar

All that crosses my mind is that you can check area of resulting region after boolean... If area of resulting region is smaller or equal than smaller (by area) reference region before boolean, then it's T otherwise it's nil...

Edited by marko_ribar

Share this post


Link to post
Share on other sites
Roy_043

You might try using vla-intersectwith.

Share this post


Link to post
Share on other sites
marko_ribar
23 minutes ago, Roy_043 said:

You might try using vla-intersectwith.

 

Although I think that this metod is available and for REGION entities, in my experience I think that it's not properly implemented for REGIONS... Still I may be misteking, further checking is needed... In BricsCAD I don't quite know for this, you may be right Roy...

Share this post


Link to post
Share on other sites
Tharwat

Maybe the fastest way is to check for the last entity before invoking the method then check after all if the same entity still the same or changed.

Share this post


Link to post
Share on other sites
Lee Mac

Perhaps something like this?

(defun reginter-p ( rg1 rg2 / rtn tr1 tr2 )
    (setq tr1 (vla-copy rg1)
          tr2 (vla-copy rg2)
    )
    (vla-boolean tr1 acunion tr2)
    (setq rtn (< (vla-get-area tr1) (+ (vla-get-area rg1) (vla-get-area rg2))))
    (vla-delete tr1)
    rtn
)

 

  • Like 1

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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