LISP Routine Request - Rotate with a reference

LISP Routine Request - Rotate with a reference

Anonymous
Not applicable
7,751 Views
16 Replies
Message 1 of 17

LISP Routine Request - Rotate with a reference

Anonymous
Not applicable

Hello,

 

I am doing a lot of rotating with a reference point or angle. A previous company I worked for used to have a routine that's hot key was RRR & would work like rotate but would automatically initiate the reference angle option after you finished your selection. 

 

Wondering if anyone here could assist me in providing a LISP that would do that? I apologize as I am a mere heathen that cannot write routines Smiley Very Happy

0 Likes
Accepted solutions (1)
7,752 Views
16 Replies
Replies (16)
Message 2 of 17

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

check this...do you know how to wrap it in lisp file or copy paste is in acad.lsp?

 

 

(defun c:rrr ()
 (command-s "._rotate" pause "" pause "_r")
 (princ) 
)  
0 Likes
Message 3 of 17

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... RRR ... would work like rotate but would automatically initiate the reference angle option after you finished your selection. 

....


 

If "your selection" would sometimes need to be more than one thing, try this:

(defun C:RRR ()
  (command "_.rotate" (ssget) "" pause "_reference")
)
Kent Cooper, AIA
Message 4 of 17

Anonymous
Not applicable

@Moshe-A wrote:

@Anonymous hi,

 

check this...do you know how to wrap it in lisp file or copy paste is in acad.lsp?

 

 

(defun c:rrr ()
 (command-s "._rotate" pause "" pause "_r")
 (princ) 
)  

 

Sorry. I should have specified that I need to rotate multiple objects at the same time. That is my mistake. I do know how to paste into a .lisp file though!

0 Likes
Message 5 of 17

Anonymous
Not applicable

@Kent1Cooper wrote:

@Anonymous wrote:

... RRR ... would work like rotate but would automatically initiate the reference angle option after you finished your selection. 

....


 

If "your selection" would sometimes need to be more than one thing, try this:

(defun C:RRR ()
  (command "_.rotate" (ssget) "" pause "_reference")
)

This works. Though it is asking for base point & then 2 points to define the reference angle. Not to be too picky but is there a way to make the base point selection the first point of the reference angle? Therefore it would trim down one click. 

0 Likes
Message 6 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:
....it is asking for base point & then 2 points to define the reference angle. ... is there a way to make the base point selection the first point of the reference angle? Therefore it would trim down one click. 

 

Try this little adjustment:

(defun C:RRR ()
  (command "_.rotate" (ssget) "" pause "_reference" "@")
)

That, of course, is valid only when the base point is, in fact, always usable as the first point of defining the reference direction.  The ROTATE command does not assume that, but if it's always true in your usage, that should do.

Kent Cooper, AIA
0 Likes
Message 7 of 17

Anonymous
Not applicable

@Kent1Cooper wrote:

@Anonymous wrote:
....it is asking for base point & then 2 points to define the reference angle. ... is there a way to make the base point selection the first point of the reference angle? Therefore it would trim down one click. 

 

Try this little adjustment:

(defun C:RRR ()
  (command "_.rotate" (ssget) "" pause "_reference" "@")
)

That, of course, is valid only when the base point is, in fact, always usable as the first point of defining the reference direction.  The ROTATE command does not assume that, but if it's always true in your usage, that should do.


This is exactly what I was looking for. The other previous options worked for what the interpretation was. Of course that is because I was not detailed enough in my initial request. Thank you much for your assistance!

Message 8 of 17

bfalconr
Contributor
Contributor

you guys are just the best, can you share any other lisp like this to speed your daily workflow,

 

Thank you in advance,

0 Likes
Message 9 of 17

Kent1Cooper
Consultant
Consultant

@bfalconr wrote:

.... can you share any other lisp like this to speed your daily workflow,

....


You would need to be more specific about what you mean by "like this."  For instance, are you looking only for routines about Rotating?

 

If you mean it more generically, Search for a particular kind of thing you're looking for.  Or, there are some threads with favorites posted, such as >this one<.

Kent Cooper, AIA
0 Likes
Message 10 of 17

bfalconr
Contributor
Contributor

You're right, I'm making shop drawings and many times I do have to rotate inclined objects to an horizontal position. your RRR lisp is saving me a lot of time, can we select an object, select base point and somehow it goes to horizontal position??

0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant

@bfalconr wrote:

... I do have to rotate inclined objects to an horizontal position. .... can we select an object, select base point and somehow it goes to horizontal position??


What kind(s) of object?  One at a time, or multiple?  For many kinds of things, or for multiple objects together, it's not clear to me what would be the aspect that you want made horizontal.  And are you talking about 2D drawing, and "inclined" meaning not aligned with the X axis, or 3D drawing, and "inclined" meaning not lying in the XY plane ?

Kent Cooper, AIA
0 Likes
Message 12 of 17

Anonymous
Not applicable

how do i put a dialog command on that rotation?

 

(command "rotate" ss "" tt "\nDirection to Connect: ")

 

but at command line it not showing the word "direction to connect" how do i change that?

 

ss is my selection unit,

tt is my preset point.

 

Thanks..

0 Likes
Message 13 of 17

Moshe-A
Mentor
Mentor

@Anonymous ,

 

In general when using (command), you collect\prepare all the arguments needed and than supply them to (command) function. this is better then pausing in mid (command) cause if the user wants to break the process, he can exit quietly (instead of getting errors).

as you can see in my code, all inputs are wrapped in a logical (and). this way responding with null reply (pressing just enter) at any prompt, will exit clean. on the other hand by doing so you are giving the dragging feature that AutoCAD offers by using pause argument. so it depend on what exactly you want to achieve?!

 

enjoy

Moshe

 

(defun c:xxx (/ ss tt rot)
 (if (and
      (setq ss (ssget))
      (setq tt (getpoint "\nSpecify base point: "))
      (setq rot (getangle tt "\ndirection to connect: "))
     )
  (command "rotate" ss "" tt (angtos rot 0 4))
 )
)

 

 

0 Likes
Message 14 of 17

Anonymous
Not applicable

Owh.. i see.. 😀

Actually i dont know how to convert that the value taken into degree..

Now it suit..

TQ for your code.. i will think of that to rearrange in my code..

0 Likes
Message 15 of 17

Automohan
Advocate
Advocate

Please help to fix the error !

(defun c:rotate_with_my_osmode ( / )
(setvar "cmdecho" 0) 
(command "rotate" (ssget) "" pause "r" "_end" "\\" "\\" "P" "_nea" pause "_per" pause)
(setvar "cmdecho" 1)
(princ))

The error was after adding "_end", "_nea" & "_per" 

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes
Message 16 of 17

Kent1Cooper
Consultant
Consultant

I get no error.  What is the error message?

Kent Cooper, AIA
0 Likes
Message 17 of 17

Automohan
Advocate
Advocate

Command: ROTATE_WITH_MY_OSMODE
Select objects: 1 found

Select objects:
No Endpoint found for specified point.
Requires valid numeric angle or two points.

"Save Energy"
Did you find this reply helpful? If so please use the Accept as Solution
0 Likes