REQ : polyline crank

REQ : polyline crank

abdulellah.alattab
Advocate Advocate
807 Views
10 Replies
Message 1 of 11

REQ : polyline crank

abdulellah.alattab
Advocate
Advocate

Crank polyline-1.JPG

 Hello everyone, I hope you will help me find a lisp that does this task. First, we choose a point along the line, and then the user can define the vertical distance either up or down, as well as the horizontal, either to the right or to the left with respect to the point, so that the program does a crank, and the program can also It does this task only if the line is horizontal, vertical or diagonal. Thank you for your cooperation, whatever it is

0 Likes
Accepted solutions (2)
808 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly like this.

You need to select the line closer to the end, which you consider the beginning. Then the left/further direction is +.

 

(defun c:crank ( / p e d k g a b r)

  (if (and (setq p (getpoint "\nSpecify a point on line: "))
	   (mapcar 'set '(e x) (entsel "\nSelect a line closer to its end: "))
	   (setq d (entget e))
	   (or (= "LINE" (cdr (assoc 0 d)))
	       (prompt "Error: Specified point not laying on a line!"))
	   (setq a (cdr (assoc 10 d)))
	   (setq b (cdr (assoc 11 d)))
	   (or (and (not (equal a p))
		    (not (equal b p)))
	       (prompt "Error: Specified point cannot be the endpoint!"))
	   (setq k (getreal "\nSpecify perpendicular distance: "))
	   (setq g (getreal "\nSpecify tangent distance: "))
	   )
    (progn
      (if (< (distance x a) (distance x b)) (mapcar 'set '(a b) (list b a)))
      (setq r (angle a b))
      (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 0) (assoc 8 d))
		       (mapcar '(lambda (p) (cons 10 p)) (list a p (polar (polar p r g) (+ r (/ pi 2)) k) (polar b (+ r (/ pi 2)) k)))))
      (entdel e)))
  (princ)
  )

 

0 Likes
Message 3 of 11

abdulellah.alattab
Advocate
Advocate

Thank you, I can say you have achieved a goal, somewhat, but for the question (Select a line close to Beginning) I noticed that it works in contrast to the task of the side of the party, too could it be implemented on a line polyline too

0 Likes
Message 4 of 11

abdulellah.alattab
Advocate
Advocate

Learn not to ask you an extra task, but even the program is complete, these missionally can be added to you, I appreciate your efforts

Crank polyline 2.JPG

0 Likes
Message 5 of 11

abdulellah.alattab
Advocate
Advocate
Crank polyline.JPG

And this task
 
0 Likes
Message 6 of 11

ВeekeeCZ
Consultant
Consultant

@abdulellah.alattab wrote:

Learn not to ask you an extra task, but even the program is complete, these missionally can be added to you, I appreciate your efforts

Crank polyline 2.JPG


 

How about simplifying the task to only this one? Meaning, it will only add the shift + "extend length".

If you will need to add something in the middle, simply break it first and then use the routine.

 

The workflow then

* pick a line/pline close to the end

* delta V

* delta H

* extension 

0 Likes
Message 7 of 11

abdulellah.alattab
Advocate
Advocate
Yes , as you explain
0 Likes
Message 8 of 11

abdulellah.alattab
Advocate
Advocate
BeekeeCz , make it flawless vectory
0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok, then try this one.

 

(defun c:crank ( / s p a y x z q r)
  
  (if (and (setq s (entsel "\nSelect line close to end: "))
	   (setq p (osnap (cadr s) "end"))
	   (setq a (angle (osnap (cadr s) "nea") p))
	   (setq y (getreal "\nSpecify perpendicular distance: "))
	   (setq x (getreal "\nSpecify tangent distance: "))
	   (setq z (getreal "\nSpecify length of extension: "))
	   (setq q (polar (polar p a x) (+ a (/ pi 2)) y))
	   (setq r (polar q a z))
	   )
    (progn
      (command "_.pline" "_non" p "_non" q "_non" r "")
      (initcommandversion)
      (command "_.join" (car s) "_l" "")))
  (princ)
  )

 

0 Likes
Message 10 of 11

abdulellah.alattab
Advocate
Advocate
Thank you
0 Likes
Message 11 of 11

abdulellah.alattab
Advocate
Advocate
Can you make this code work with polyline at selection stage
0 Likes