Jump to content

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


gsc

Recommended Posts

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 7 months later...
On 11/20/2020 at 6:02 AM, Lee Mac said:

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
)

 

thank ,  this is i whant code

Link to comment
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
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...