Jump to content

Recommended Posts

Posted

hello guys,Assuming that there is (setq lst( p1 p2 p3 p4)) in the point table, how to judge whether there is a point pair in the same direction as the SP-EP point in lst, and return a new point pair table if it exists. In the legend, p1-p4 It is consistent with the direction of p2-p3 and SP-EP

 

 

TEST.png

Posted
10 minutes ago, ekko said:

hello guys,Assuming that there is (setq lst( p1 p2 p3 p4)) in the point table, how to judge whether there is a point pair in the same direction as the SP-EP point in lst, and return a new point pair table if it exists. In the legend, p1-p4 It is consistent with the direction of p2-p3 and SP-EP

 

 

TEST.png

@ekko Please upload  "legend" as dwg.

As far as I know, acad can not edit such legend  

 

 

Posted
15 minutes ago, devitg said:

@ekko Please upload  "legend" as dwg.

As far as I know, acad can not edit such legend  

 

 

@devitg this was an oversight on my part, I'm sorry. I'm about to upload a legend

TEST.png

Posted
Just now, ekko said:

@devitg this was an oversight on my part, I'm sorry. I'm about to upload a legend

 

 

test.dwg

Posted
4 hours ago, ekko said:

In the legend, p1-p4 It is consistent with the direction of p2-p3 and SP-EP

@ekko

As I can see , p1-p4 , is not consistent with p2-p3 , neither with SP-EP 

Furthermore , WHAT do it mean CONSISTENT , for you in this case.?

 

 

 

 

 

 

Posted (edited)

Would it not mean ang1-ang2 < 90 (/pi 2.0) is a match.

Edited by BIGAL
Posted
3 hours ago, devitg said:

@ekko

As I can see , p1-p4 , is not consistent with p2-p3 , neither with SP-EP 

Furthermore , WHAT do it mean CONSISTENT , for you in this case.?

 

 

 

 

 

 

There is something wrong with my expression. I mean that from the vector of P1-P4 and the vector of SP-EP, they are in the same direction. Even if they are not parallel, can you judge?

Posted
1 hour ago, BIGAL said:

Would it not mean ang1-ang2 < 90 (/pi 2.0) is a match.

The logic you provided is correct. It's just about this legend. If you rotate 180 degrees in the graph, then it will be wrong to judge (* PI 0.5). Maybe you can adapt it by judging the angle. Mathematics is my weakness, which is difficult for me.

Posted

You can get the 2 angles then just think about the difference between them remember they are in radians. (/ pi 2.0) = 90 degrees.

Posted (edited)
On 4/3/2023 at 4:38 AM, devitg said:

@ekko

As I can see , p1-p4 , is not consistent with p2-p3 , neither with SP-EP 

Furthermore , WHAT do it mean CONSISTENT , for you in this case.?

 

 

 

 

 

 

test2.thumb.PNG.d17eebb05e8a3910a3e9934861781ad9.PNG

(vl-load-com)
(defun c:test (/ p1 p2 p3 p4 e obj sp ep sp-ep same-dir)
  (initget 1)
  (if (and
	(setq p1 (getpoint "\nPoint1:"))
	(setq p2 (getpoint "\nPoint2"))
	(setq p3 (getpoint "\nPoint3"))
	(setq p4 (getpoint "\nPoint4"))
	(setq e (car (entsel "\nCurve:")))
      )
    (progn
      (setq obj	  (vlax-ename->vla-object e)
	    sp	  (vlax-curve-getStartpoint obj)
	    ep	  (vlax-curve-getEndpoint obj)
	    sp-ep (list sp ep)
      )
      (setq same-dir (get-same-direction p1 p2 p3 p4 sp-ep))
      (princ "\nthe ones in the same direction as (XL line) are:")
      (princ (mapcar 'cadadr same-dir))
    )
  )
  (princ)
)


(defun get-same-direction (p1 p2 p3 p4 sl / edges v1 lst)
  ;;Compute vectors for all lines
  (setq	edges (list
		(list (mapcar '- p2 p1) "A,B") ; AB p1,p2
		(list (mapcar '- p1 p2) "B,A") ; BA p2,p1
		(list (mapcar '- p4 p1) "A,D") ; AD p1,p4
		(list (mapcar '- p1 p4) "D,A") ; DA p4,p1
		(list (mapcar '- p3 p2) "B,C") ; BC p2,p3
		(list (mapcar '- p2 p3) "C,B") ; CB p3,p2
		(list (mapcar '- p4 p3) "C,D") ; CD p3,p4
		(list (mapcar '- p3 p4) "D,C") ; DC p4,p3
	      )
  )

  ;; Calculate the Curve vector
  (setq v1 (mapcar '- (cadr sl) (car sl)))
  ;; sl is the starting point and end point of Curve, use cadrr and car to get the end point and starting point of the slash
  ;; Calculate the dot product of Curve and each edge segment
  (foreach x edges
    (if	(> (* (car v1) (caar x)) 0)
      (setq lst (cons (list v1 x) lst))
    )
  )
  lst
)

@devitg, @BIGAL  .I tried to write a piece of code, it is only for the first example, and the points must be selected in the order of p1,p2,p3,p4 in order to return the correct result. How can it be done, apply all examples, and get the correct result?

test2.dwg

Edited by ekko

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