Lisp rotate objects given basepoint, radius and distance

Lisp rotate objects given basepoint, radius and distance

cool.stuff
Collaborator Collaborator
1,072 Views
11 Replies
Message 1 of 12

Lisp rotate objects given basepoint, radius and distance

cool.stuff
Collaborator
Collaborator

Hi!

 

I've found this lisp and it works properly 🙂

I give a circle/arc and given a distance, it rotates selected entities based on computed angle.

However, as I have different entities on different points, i have to constantly draw circles in order to perform required rotation.

 

Could anyone please change it to ask for a base point, a radius and a distance?

It would simplify my work a lot 🙂

 

The credits are given in the link where I found it 🙂

 

;https://www.cadtutor.net/forum/topic/51964-i-want-to-rotate-by-distance/
(defun roang ( / oldang obj1 rad centpt ang)
(setq oldang (getvar "aunits"))
(setvar "aunits" 3)
(princ "\nPick Arc or circle")
(setq obj1 (entget (car (entsel))))
(setq rad (cdr (assoc 40 obj1)))
(setq centpt (cdr (assoc 10 obj1)))
(setq ang (/ (getreal "\nEnter Arc distance") rad))
(princ "\nPick object to rotate")
(setq obj2 (entsel))
(command "rotate" obj2 "" centpt ang)
(setvar "aunits" oldang)
)

(roang)

 

 

Many thanks in advance 🙂

0 Likes
Accepted solutions (2)
1,073 Views
11 Replies
  • Lisp
Replies (11)
Message 2 of 12

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this.

 

(defun c:RotateByArcLen ( / s p r l)

  (if (and (setq s (ssget "_:L"))
	   (setq p (getpoint "\nSpecify base point: "))
	   (setq r (getdist "\nSpecify radius: "))
	   (setq l (getdist "\nSpecify arc lenght: "))
	   )
    (command "_.rotate" s "" "_non" p (angtos (/ l r) (getvar 'aunits) 10)))
  (princ)
  )

 

0 Likes
Message 3 of 12

cool.stuff
Collaborator
Collaborator

Works like a charm!!! 🙂

Many many thanks 🙂

0 Likes
Message 4 of 12

cool.stuff
Collaborator
Collaborator
Hello again! 🙂

Could you please change this lisp?
I would like it to store the selected point, the defined radius and arc length.
Then, when it runs again, it it possible to change one of these variables..
Do you think you could do it please?
I come across multiple objects that requires same "parameters" but the drawing is constantly changing, hence my request.

Many many thanks in advance 🙂
0 Likes
Message 5 of 12

ВeekeeCZ
Consultant
Consultant

The reference point is the same?!

Would you post some video or explanatory dwg that would illustrate what sort of multiple edits you do?

0 Likes
Message 6 of 12

cool.stuff
Collaborator
Collaborator
Could you please tell me how to make a video? 🙂
For instance, I run the lisp and chose a point (say 2,2,0) and give for radius 100 (which is stored in a variable) and for arc length 10 (which is also stored).
Next time I run this lisp it displays on console base point 2,2,0, radius = 100; arc length = 10. Then just by selecting objects, they are rotated based on it..

I know it is very simple to say it, but not in doing it..

Sorry for not being more helpful..
many may thanks 🙂
0 Likes
Message 7 of 12

cool.stuff
Collaborator
Collaborator
I found this on a lisp that stores the input user values for next run:

(defun c:ShearDist (/ done flg osd)

(or *var1* (setq *var1* 1.)) ;; set defaul value
(or *var2* (setq *var2* 1.))
(setq osd (getvar 'offsetdist))

(while (not done)
(princ (strcat "Current settings: Shear: " (rtos *var1*)))
(initget "Scale Through Erase Layer")
(setq flg (getdist (strcat "\nSpecify offset distance or [Scale/Through/Erase/Layer] <" (rtos *var2*) ">: ")))
(if (= flg "Scale")
(progn
(initget 3) (setq *var1* (getdist "\nShear factor: ")))
(setq done T)))

(if (numberp flg)
(command "_.offset" (* (setq *var2* flg) *var1*))
(progn
(setvar 'offsetdist (* *var2* *var1*))
(command "_.offset" flg)))
(while (> (getvar 'cmdactive) 0) (command pause))
(setvar 'offsetdist osd)
(princ)
)

Does it helps? 🙂
0 Likes
Message 8 of 12

ВeekeeCZ
Consultant
Consultant
Accepted solution

Maybe this workflow would be better... just keep on selecting... RT when you're done.

If you need to re-set the previous values, just use the regular built-in feature UP-ARROW and ENTER.

 

(defun c:RotateByArcLen ( / s p r l)
  
  (if (and (setq p (getpoint "\nSpecify base point: "))
	   (setq r (getdist "\nSpecify radius: "))
	   (setq l (getdist "\nSpecify arc lenght: "))
	   )
    (while (setq s (ssget ":S"))
      (command "_.rotate" s "" "_non" p (angtos (/ l r) (getvar 'aunits) 10))))
  (princ)
  )

 

Message 9 of 12

cool.stuff
Collaborator
Collaborator
It is not working.. when I select a line the lisp stop running..
Could you help?
Maybe I'm doing something wrong.. sorry
0 Likes
Message 10 of 12

ВeekeeCZ
Consultant
Consultant

Use updated code. 

 

How to make a video (should be in English... cant tell)

https://www.cadforum.cz/en/how-to-quickly-record-a-video-from-a-cad-application-tip13513

Message 11 of 12

cool.stuff
Collaborator
Collaborator
Works!!! 🙂 many many thanks for all your help and patience 🙂

PS: the url is in russian, but with translator I'll get there 🙂

Many thanks again!!! 🙂
0 Likes
Message 12 of 12

ВeekeeCZ
Consultant
Consultant

You're mistaken. It was not Russian.