Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help me understand this routine.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
maikhanhmst
676 Views, 4 Replies

Please help me understand this routine.

Hi,

Could someone please explain to me some issues of this routine? There're somethings I couldn't understand.

1. This routine that rotates multiple objects around their individual base points. So what is a base point or an intersection point?
2. How does (setq ss (ssx)) work?
3. How does (if ss (...)) work?
4. What infomation of the objects do (assoc 10 elist) and (entget ename) statements retrieve?

Khanh.

;* Rotate Multiple
;* Rotates many entities around their respective basepoints ;* allows selection by AUTOCAD selection sets or SSX. ;* Written by David Husch, January 1991 (defun c:rotmult () (prompt "Select Entities to Rotate, <ENTER> for SSX.") (setq ss (ssget)) (if (not ss) (setq ss (ssx))) (setq num (sslength ss)) (setq x 0) (if ss (if (setq ang (getreal "Enter Rotation Angle: ")) (repeat num (setq ename (ssname ss x)) (setq elist (entget ename)) (setq pnt (cdr(assoc 10 elist))) (command "Rotate" ename "" pnt ang) (setq x (1+ x)) ) ) ) )

 

4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: maikhanhmst

I could explain it all, but I think you would learn more if you read about those AutoLISP functions in Help.  That should answer most of your questions, and you'll also learn other related things about the functions that will be helpful to you in the future.  The one exception is (ssx), which is not a native AutoLISP function, and must be someone's specialty selection function -- maybe a Search of files in your system will turn up the definition of that, and/or it might be somewhere on these Forums or other websites.  After learning what (assoc) does, you should probably also look at the DXF Reference to learn what the entity-data entries starting with 10 represent for different entity types, because you won't find that in the Help entries for AutoLISP functions.

Kent Cooper, AIA
Message 3 of 5
rkmcswain
in reply to: Kent1Cooper

Kent1Cooper wrote:
...The one exception is (ssx), which is not a native AutoLISP function, and must be someone's specialty selection function --

I suspect it may be the (ssx) function as defined in "C:\Program Files\Autodesk\AutoCAD 2015\Express\ssx.lsp" (or similar path, depending on your version).

 

R.K. McSwain     | CADpanacea | on twitter
Message 4 of 5
paullimapa
in reply to: maikhanhmst

You should lookup all the functions and what they actually do by going to this URL:
http://docs.autodesk.com/ACDMAC/2013/ENU/PDFs/acdmac_2013_autolisp_developers_guide.pdf
I will try and comment as much as I can below:

(
defun c:rotmult () ; defun - defines a function in this case c:rotmult is the name of the new command function that you can enter at the command prompt to start the command: ROTMULT

(prompt "Select Entities to Rotate, <ENTER> for SSX.") ; prompt - prints onto the command prompt screen a statement in this case: Select Entities to Rotate, <ENTER> for SSX.

(setq ss (ssget)) ; setq - sets a variable ss equal to ssget - selection set

(
if (not ss) ; if ss does not exist which means the user hit <Enter> instead of selecting objects

(
setq ss (ssx))) ; setq - sets ss to whatever is defined in function ssx.lsp which is provided in the AutoCAD Express Tools

(setq num (sslength ss)) ; setq - sets num to sslength - the length of the selection set which really means the number of items selected

(setq x 0) ; setq - sets variable x to start off as number 0

(if ss ; if - if ss exists which means something is selected

(if (setq ang (getreal "Enter Rotation Angle: ")) ; if - if an angle is entered using the getreal function

(repeat num ; repeat the next statements based on num which is the number of selection items

(setq ename (ssname ss x)) ; setq variable ename and use ssname function to get the entity name of the object on the 1st item of the selection set. The first item always starts at 0 which is why x was initially set equal to 0

(setq elist (entget ename)) ; setq variable elist using entget function to grab the entity data

(setq pnt (cdr(assoc 10 elist))) ; setq variable pnt code 10 from the entity data which is usually the base point of the entity

(command "Rotate" ename "" pnt ang) ; Use AutoCAD's built-in Rotate command to change the entity ename from the base point pnt to the given rotation angle of ang

(setq x (1+ x)) ; use the 1+ function to add 1 to the variable x so that when the steps are repeated it'll be applied on the next selected entity in this case the second item in the selection set

) ) ) )

Area Object Link | Dwg Setup | Feet-Inch Calculator
Exchange App Store

 

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 5
maikhanhmst
in reply to: Kent1Cooper

Thanks for your recommends.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost