Call for help , cranking polyline

Call for help , cranking polyline

abdulellah.alattab
Advocate Advocate
7,338 Views
37 Replies
Message 1 of 38

Call for help , cranking polyline

abdulellah.alattab
Advocate
Advocate

Hello everyone, I need help drawing a bent-up or bent-down, cranking polyline.

 

The steps that the user performs are as follows: First, the user enters the distance L1 and then L2 either through the keyboard or by obtaining the distance by clicking on points P1 and P2 to obtain the distance L1 and by clicking on points P2 and P3 to obtain L2. Second, the user enters the parameters F1 and F2 through the keyboard only and the user enters the height H either through the keyboard or by choosing the distance between two points, whatever the user chooses. Third, the user enters the value of the angle through the keyboard, provided that the angle is between 0 and 90 degrees only. Fourth, the user chooses a point close to the end of the polyline at which the program will execute the task. If possible, the user chooses a point above or below the line to determine the side on which it will draw, either above or below the line. The program can execute the task on any polyline at any angle relative to the UCS.

 

It is preferable for the program to work on one side of the line, because the distances L1, L2 and the coefficients F1 and F2 often differ for each side of the line, and the task may be performed on one side or on both sides of the multi-line.

 

Thank you for all your efforts to make our work easier.

0 Likes
Accepted solutions (1)
7,339 Views
37 Replies
Replies (37)
Message 21 of 38

abdulellah.alattab
Advocate
Advocate

Perhaps with anxiety, I made mistakes in the previous explanation. Perhaps things are clearer in the following attached image.

0 Likes
Message 22 of 38

abdulellah.alattab
Advocate
Advocate

Untitled-13.png

Sorry for not explaining what I want clearly, I wanted to create a contraction at any of the endpoints and draw a crank from the new endpoint resulting from the contraction

0 Likes
Message 23 of 38

Sea-Haven
Mentor
Mentor

Just a comment you can combine steps 1 & 2 into 1, when you pick say a line near an end you can work out which end you have picked as well as which line.

 

Step 3 can enter L1 by using (getdist endpt "\nPick length or enter value ") and using the correct endpt

 

If a line v's a pline a subtle change to code. For the pline its simplest to reverse the direction of the pline so endpt chosen is correct.

 

 

(setq ent (entsel "\nSelect line near start end Press Enter to exit "))
  (setq ename (entget (car ent)))
  (setq pt (cadr ent))
  (setq pt1 (cdr (assoc 10 ename)))
  (setq pt2 (cdr (assoc 11 ename)))
  (setq ang2 (angle pt1 pt2))
  (setq d1 (distance pt pt1))
  (setq d2 (distance pt pt2))
  (if (> d1 d2)
   (setq tmp pt1
     pt1 pt2
     pt2 tmp)
  )

(setq L1 (getdist pt1 "\nPick a point or enter distance "))
(setq L2 (getdist pt1 "\nPick a point or enter distance "))

 

 

 

 

Message 24 of 38

abdulellah.alattab
Advocate
Advocate

I lost focus, you can suggest anything you see fit, to reach the result

0 Likes
Message 25 of 38

abdulellah.alattab
Advocate
Advocate

Is it possible to do this?

0 Likes
Message 26 of 38

abdulellah.alattab
Advocate
Advocate

@komondormrex 

@Kent1Cooper 

Nothing is impossible

0 Likes
Message 27 of 38

Sea-Haven
Mentor
Mentor

Like the others it is in my "To do list" just have to find time. The some one else may get it done sooner.

Message 28 of 38

abdulellah.alattab
Advocate
Advocate

I don't think you have any intention of doing that.

0 Likes
Message 29 of 38

Sea-Haven
Mentor
Mentor

Like others here we supply answers when we can, life gets in the way sometimes. like going fishing and having a holiday. You have to be patient it is in my to do list. 

Message 30 of 38

abdulellah.alattab
Advocate
Advocate

You mean it, if you don't intend to do it, don't promise others

0 Likes
Message 31 of 38

Sea-Haven
Mentor
Mentor

I am on holidays and pretty busy with other holiday stuff, I dont seem to be able to find time it may be saturday before I can get to it. Some one else may jump in.

0 Likes
Message 32 of 38

abdulellah.alattab
Advocate
Advocate

You rarely find a person whose good deeds are rooted in his origins.

You deserve every good things 

0 Likes
Message 33 of 38

abdulellah.alattab
Advocate
Advocate

Waiting for the promise

0 Likes
Message 34 of 38

Sea-Haven
Mentor
Mentor

Working on it. Gettint the up down to work by entering a -ve angle.

 

0 Likes
Message 35 of 38

abdulellah.alattab
Advocate
Advocate

Any solution was acceptable , dont worry 

0 Likes
Message 36 of 38

abdulellah.alattab
Advocate
Advocate

This is my mistake in explaining, I hope the following picture includes it, believe me there are people at work who are frustrated, they have a lot of drawings, hoping that the task will be completed, and they thank you

0 Likes
Message 37 of 38

abdulellah.alattab
Advocate
Advocate

A, B any values can user enter it via getdistance or key board , i am sorry , our drafter say " it was better if add A,B " to be comperhansive lisp 

0 Likes
Message 38 of 38

Sea-Haven
Mentor
Mentor

Give this a try, it does pop a dcl so you can fine tune the L1 & L2 if required same as the F values. To go down enter a -ve angle eg -30.

Make sure you have multi getvals in a support path.

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/call-for-help-cranking-polyline/td-p/13362612/page/2
; 
; Cranked reobar By AlanH March 2025
; Version 2

(defun c:reobar ( / oldsnap ans l1 l2 f1 f2 l3 l4 pt1 pt2 pt3 pt4)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(while (setq ent (entsel "\nSelect line near start end Press Enter to exit "))
  (setq ename (entget (car ent)))
  (setq typ (cdr (assoc 0 ename)))
  (if (= typ "LWPOLYLINE")
  (progn 
    (command "explode" ename)
	(alert "please run again using converted pline to a line")
	(exit)
  )
  (princ)
  )
  (setq rev "")
  (setq pt (cadr ent))
(setq pt1 (cdr (assoc 10 ename)))
(setq pt2 (cdr (assoc 11 ename)))
(setq d1 (distance pt pt1))
(setq d2 (distance pt pt2))
(if (> d1 d2)
 (setq tmp pt1
   pt1 pt2
   pt2 tmp
   rev "Y")
)
  (setq ang2 (angle pt1 pt2))

(setq L1 (getdist pt1 "\nPick a point or enter distance "))
(setq pt3 (polar pt1 ang2 l1))
(setq L2 (getdist pt3 "\nPick a point or enter distance "))

(setq ans (AH:getvalsm (list "Enter values " "L1" 8 7(rtos l1 2 2)  "L2" 8 7 (rtos l2 2 2) "F1" 5 4 "5" "F2" 5 4 "5" "Height" 5 4 "20" "Angle"  5 4 "30")))

(setq l1 (atof (nth 0 ans))
l2 (atof (nth 1 ans))
f1 (atof (nth 2 ans))
f2 (atof (nth 3 ans))
ht (atof (nth 4 ans))
ang (atof (nth 5 ans))
)

(setq ang3 (* pi (/ ang 180.0)))

(cond 
((and (>= ang 0.0) (= rev "Y"))(setq ang3 (- pi ang3)))
((and (< ang 0.0) (= rev "Y"))(setq ang3 (+ pi (abs ang3))))
((>= ang 0.0)(princ))
((< ang 0.0)(setq ang3 (+ (* pi 2.) ang3)))
)


(setq l3 (/ l1 f1))
(setq l4 (/ l2 f2))

(setq pt2 (polar pt1 ang2 (- l1 l3)))
(if (= rev "Y")
(entmod (subst (cons 10 pt2) (assoc 10 ename) ename))
(entmod (subst (cons 11 pt2) (assoc 11 ename) ename))
)

(setq h (abs (/ ht (sin (abs ang3)))))
(setq pt3 (polar pt2 ang3 h))
;(setq dist (+ l4 (- l3 (* (cos (abs ang3)) ht))))
(setq pt4 (polar pt3 ang2 l4))
(command "line" pt2 pt3 pt4 "")
)

(setvar 'osmode oldsnap)
(princ)

)
(c:reobar)