Jump to content

If a line coordinate touches a circle entity of a block- say yes


Recommended Posts

Posted

Hello CadTutorers:)

 

My question of the day is described in pic attached.

 

Things like, functions to use for such problem or links where this subject was covered will be appreciated

question1000.jpg

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • Qonfire

    13

  • Tharwat

    5

  • pBe

    2

  • David Bethel

    1

Top Posters In This Topic

Posted Images

Posted

This helps.

 

 

(defun get_all_inters_in_SS (SS /
           SSL ;length of SS
           PTS ;returning list
           aObj1 ;Object 1
           aObj2 ;Object 2
           N1  ;Loop counter
           N2  ;Loop counter
           iPts ;intersects
           )
  (setq N1 0 ;index for outer loop
  SSL (sslength SS))
  ; Outer loop, first through second to last
  (while (< N1 (1- SSL))
    ; Get object 1, convert to VLA object type
    (setq aObj1 (ssname SS N1)
    aObj1 (vlax-ename->vla-object aObj1)
    N2 (1+ N1)) ;index for inner loop
    ; Inner loop, go through remaining objects
    (while (< N2 SSL)
      ; Get object 2, convert to VLA object
      (setq aObj2 (ssname SS N2)
      aObj2 (vlax-ename->vla-object aObj2)
      ; Find intersections of Objects
      iPts (vla-intersectwith aObj1
       aObj2 0)
      ; variant result
      iPts (vlax-variant-value iPts))
      ; Variant array has values?
      (if (> (vlax-safearray-get-u-bound iPts 1)
       0)
  (progn ;array holds values, convert it
    (setq iPts ;to a list.
     (vlax-safearray->list iPts))
    ;Loop through list constructing points
    (while (> (length iPts) 0)
      (setq Pts (cons (list (car iPts)
          (cadr iPts)
          (caddr iPts))
          Pts)
      iPts (cdddr iPts)))))
      (setq N2 (1+ N2))) ;inner loop end
    (setq N1 (1+ N1))) ;outer loop end
  Pts) ;return list of points found

Posted

I think the following function will be of a help , read Help Documentation for more explanations

vla-intersectwith

Posted

good one,thanks,i'm gonna look into it

Posted

I guess this is enough as an example :)

 

(defun c:Test (/ l b) (vl-load-com)
 (if (and (setq l (car (entsel "\n Select line :")))
          (setq b (car (entsel "\n Select Block :")))
     )
   (if (vlax-invoke (vlax-ename->vla-object l) 'Intersectwith
         (vlax-ename->vla-object b)
         AcExtendNone
       )
     (alert "Yes, The two objects are Intersected with each others")
     (alert "No, There are not Intersected at all ")
   )
 )
 (princ)
)

Posted

- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

 

Do you evaluate your aim while reaching it? (i mean continuing to analyze the importance of aim, effort to reward ratio?

 

My opinion, is that you described a fanatical way of thinking. I did't say its bad.

 

Sorry for getting of the topic,

Posted
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

 

Do you evaluate your aim while reaching it?

 

A very good question , ;)

 

Actually , I haven't got satisfied yet , so that makes me looking for more all the time .:P

Posted

Who knows the true and right aim, that people should try to reach(except GOD)? Me, i'm just gonna hope that I got the aim right.

Posted
Who knows the true and right aim, that people should try to reach(except GOD)? Me, i'm just gonna hope that I got the aim right.

So , did you get the aim of the code right now or not yet ?

Posted

I didn't see it, you reply too fast:), no i didn't get it yet,but i like that simplified structure

Posted

A basic test could be:

 

(equal (distance center_of_circle end_point_of_line ) radius_of_circle fuzz)

 

-David

Posted

thank you for reply,i will check what is that line about.

Posted

(while (< N1 (1- SSL))
    ; Get object 1, convert to VLA object type
    (setq aObj1 (ssname SS N1)
    aObj1 (vlax-ename->vla-object aObj1)
    N2 (1+ N1)) ;index for inner loop
    ; Inner loop, go through remaining objects
    (while (< N2 SSL)
      ; Get object 2, convert to VLA object
      (setq aObj2 (ssname SS N2)
      aObj2 (vlax-ename->vla-object aObj2)
      ; Find intersections of Objects
      iPts (vla-intersectwith aObj1
       aObj2 0)

 

We get first item inn selection set objet1 and than we are coparing to a NEXT objet2 in selection set.My question is, what if intersection occurs between objet1 and objet 4.

Posted

(defun c:Test (/ l b) (vl-load-com)
 (if (and (setq l (car (entsel "\n Select line :")))
          (setq b (car (entsel "\n Select Block :")))
     )
   (if (vlax-invoke (vlax-ename->vla-object l) 'Intersectwith
         (vlax-ename->vla-object b)
         AcExtendNone
       )
     (alert "Yes, The two objects are Intersected with each others")
     (alert "No, There are not Intersected at all ")
   )
 )
 (princ)
)

 

You wrote a lisp on my question.its like coming to university first and obtaining phd on a same day.thanks.

Posted

Qonffire,

 

Pardon my question but, you can see if the line intersects the blocks or not . and by the title of your thread

 

If a line coordinate touches a circle entity of a block- say yes

 

You mean either the startpoint or the endpoint but not in betweeen them? [from your attached image] does it mean that if its not endpoint/starpoint of line then the test result is nil? or you really menat to say Block intersects at any coordinate of the line? will there be another set of functions to follow if the test is T? i would guess there would be, right? so whats the main function of your routine?

Posted

outer loop...inner loop..duahhh, this was posted before i saw your last response,i should read the comments ,i was concentrated on data in watch.

Its just my technical vocabulary is limited. I wanted to see how to find the "coordinates" of intersecting points.

Posted

block intersects at any point on line,I'm ok for now. Thanks a lot

 

 

Qonffire,

 

Pardon my question but, you can see if the line intersects the blocks or not . and by the title of your thread

 

 

 

You mean either the startpoint or the endpoint but not in betweeen them? [from your attached image] does it mean that if its not endpoint/starpoint of line then the test result is nil? or you really menat to say Block intersects at any coordinate of the line? will there be another set of functions to follow if the test is T? i would guess there would be, right? so whats the main function of your routine?

Posted

You wrote a lisp on my question.its like coming to university first and obtaining phd on a same day.thanks.

 

I did not get your point

Posted
block intersects at any point on line,I'm ok for now. Thanks a lot

 

Thats good to know, But I know there's more to it that just T or nil, can you show or descrbe for us the whats going to happen next after the test?

Posted
I did not get your point

 

It's ok.I was trying to joke.

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