I want to create a simple "rotate" command with AutoLisp, so this is the code I wrote:
(defun C:myfunc()
(setq p1 (getpoint "\nPick first POINT on the screen:\n"))
(setq p2 (getpoint "\nPick second POINT on the screen:\n"))
(command "line" p1 p2 "")
(setq ss1 (ssget p2))
(command "rotate" ss1 p2 "90" "")
(princ )
)
I insert two points, p1 and p2 and create a line which connects them. After that I create the ss1 object which is the line p1-p2. Finally I attempt to rotate the line from base point p2 for 90 degrees.
I insert the code in AutoCad, but instead of creating the rotated line, it asks to insert manually the base point as well as the angle, so I guess that there is a problem with the command "rotate" ...
line.
Any suggestions would be appreciated.
From what I've seen online, you have two problems.
ROTATE
does not take a selection set but an entity name
Missing an extra ""
before the rotation point.
(defun C:myfunc()
(setq p1 (getpoint "\nPick first POINT on the screen:\n"))
(setq p2 (getpoint "\nPick second POINT on the screen:\n"))
(command "line" p1 p2 "")
(setq ss1 (ssget p2))
(command "rotate" (entlast) "" p2 "90")
(princ )
)
Reference: AutoLISP: Rotate Multiple Objects Around Their Base Point
As a side note, it usually helps me to try the command manually to make sure you are responding to all the correct prompts with the correct data/values.