Jump to content

How to write lisp to following problem?


asmmanikanda

Recommended Posts

In attached image AB=155,Ay=95,yB=65,yx=75,Ayx=xyB=90 degree, need lisp to point x if enter distance from A and height of xy.  Any one help to solve this problem 

IMG_20200809_095922.jpg

Link to comment
Share on other sites

Simple double polar, get angle of line, 1st polar is point at distance from end, 2nd polar is from new pt 90 for xy distance not rocket science.

 

Ok tricky bit but simple solution, pick line 1 end this is end for measure distance, a + or - offset will go left or right.

 

Do you know any lisp ?

 

here is the end check

(setq tp1 (entsel "\nSelect line near end : "))
	(setq tpp1 (entget (car tp1)))
	(setq pt1 (cdr (assoc 10 tpp1)))
	(setq pt1 (list (car pt1) (cadr pt1) 0.0)) ;reset z to zero
	(setq pt2 (cdr (assoc 11 tpp1)))      
	(setq pt2 (list (car pt2) (cadr pt2) 0.0)) ;reset z to zero

	(setq pt3 (cadr tp1))
	
	(setq d1 (distance pt1 pt3))
	(setq d2 (distance pt2 pt3))
		(if (> d1 d2)
		(progn 
			(setq temp pt1)
			(setq pt1 pt2)
			(setq pt2 temp)
		)
		)
		(setq ang (angle pt1 pt2)

 

Link to comment
Share on other sites

Or , something similar :

 

-- a NEGATIVE value for distance d1, will calculate the points ,  OUTSIDE of object / direction 1-2 .

 

- a POSITIVE value for distance d2 , will calculate the points , on the LEFT side of direction 1-2 .

- a NEGATIVE value for distance d2 , will calculate the points , on the RIGHT side of direction 1-2 .

 

(while (and (progn (reDraw) (setq d1 nil  d2 nil  o nil  p1 nil p2 nil  p12 nil  l (getVar "cLayer")  r 0.2) )
        (if (setq o (car (entSel "\n  Select  a  LINIAR  Object  :  <  Enter  =  2  Points  or  Cancel  >  :  ")))
         (setq p0 (cdr (assoc 10 (entGet o)))  oV (vlax-Ename->Vla-Object o)  p1 p0)
         (and
          (setq p1 (getPoint "\n  Reference  Point  1  :  <  Enter  =  Cancel  >  :  "))
          (setq p2 (getPoint p1 "\n  Reference  Point  2  :  <  Enter  =  Cancel  >  :  "))
         )
        ) ; if o
    )
 (while (and (progn (reDraw) (if (and p1 p12) (grDraw p1 p12 5) ) (if o (setq p1 p0) (grDraw p1 p2 1)) (if (and p12 pX) (grDraw p12 pX 3) ) T)
         (setq oT (if o (strCat "\n   Object  :  " (substr (vla-Get-ObjectName oV) 5) "  ;  Layer  =  " (vla-Get-Layer oV) "  ;  Length  =  "
          (RtoS (if (vl-Some '(lambda (x) (if (vlax-Property-Available-P oV x) (setq oL (vlax-Get-Property oV x)) )) '("Length" "ArcLength" "Circumference")) oL 0) 2 4) "") )  )
         (setq pX nil  d1 (getDist p1 (strCat oT "\n  Get  Distance  ALONG  Line  P1-P2  =  " (RtoS (if o 0 (distance p1 p2) ) 2 4) "  :  <  Enter  =  Cancel  >  :  ")) )
         (if o
          (setq p12 (vlax-Curve-GetPointAtDist o d1)  pa12 (vlax-Curve-GetParamAtDist o d1)
                p1 (vlax-Curve-GetPointAtParam o (fix pa12))  p2 (vlax-Curve-GetPointAtParam o (fix (1+ pa12))) )
          T) ; if
         (progn (reDraw) (if (not o) (grDraw p1 p2 1)) (if (and p1 p12) (grDraw p1 p12 5) ) (if (and p12 pX) (grDraw p12 pX 3) ) T)
         (setq d2 (getDist p12 "\n  Get  Distance  PERPENDICULAR  on  Line  P1-P2  :  <  Enter  =  Cancel  >  :  "))
        )
  (if o T (setq p12 (polar p1 a d1) ) ) ; if o
  (setq a (angle p1 p2)  pX (polar p12 (+ (/ pi 2) a) d2) ) ;
  (entMake (list '(0 . "Circle") (cons 8 l) '(6 . "ByLayer") '(62 . 256) (cons 10 pX) (cons 40 r) )  ) ; end of e
 ) ; wh d
) ; wh p

 

Perpendicular Points at Dist 1.jpg

 

Perpendicular Points at Dist 2.jpg

 

Perpendicular Points at Dist 3.jpg

 

Perpendicular Points at Dist 4.jpg

 

Edited by Costinbos77
Change the lisp code and added more pictures .
Link to comment
Share on other sites

12 hours ago, BIGAL said:

Like the idea distance along a pline.

Thanks BIGAL , 

 

I done something similar for interpolating Height between 2 or 3 Reference points , using grRead function .

 

Interpol points 1.jpg

 

 

 

Interpol points 22.jpg

Edited by Costinbos77
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...