24 June 2013

Rotate command in AutoLISP || How to rotate the object in AutoCAD using Autolisp?

Hi friends, in this article I will explain about the Rotate command in the AutoLISP or AutoCAD, how to use the Rotate command in AutoCAD, how to write the code for Rotate in AutoLISP.
First we know about, how to use Rotate in AutoCAD. 
  • Open the AutoCAD, Write Rotate or ro and press enter. It will ask the following. 
Command: rotate
Select objects: 1 found
Select objects:
Specify base point:
Specify rotation angle or [Copy/Reference] <90>:
  • Then the selected object rotates to the 90 degrees. The below figure shows clearly how to object was rotated. 

  • Open AutoLISP Editor,Write the below code or Simply Copy and Paste the below code.

(defun c:rot()
(setq p1(getpoint "\n Pick First Point of the line")
p2(getpoint "\n Pick Second Point of the line")
)
(command "line" p1  p2 "")(setq s(entlast))
(command "rotate" s "" p1 "90" "")
)
  • In the above code (setq s(entlast)) is the line because it store the object.
  • Save the code as rot.lsp. Open AutoCAD and type the below commands. 

(load "rot")
C:ROT
Command: rot
Pick First Point of the line
Pick Second Point of the line
The below figure shows the output of the above code.


Thank you for reading my blog AutoLISp-Roja..If you like my blog please like the facebook page AutoLISPRoja


No comments:

Post a Comment