Quick Search for:  in language:    
Align,Blocks,something,else,like,cirlclesuse,
   Code/Articles  |  Newest/Best  |  Community  |  Jobs  |  Other  |  Goto  | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
LISP Stats

 Code: 6,703. lines
 Jobs: 7. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for LISP.
There is currently no new code. Please check back soon.
Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Aligning Blocks

Print
Email
 
VB icon
Submitted on: 4/13/2003 6:32:13 AM
By: ali s 
Level: Beginner
User Rating: Unrated
Compatibility:Auto Lisp

Users have accessed this code 1857 times.
 
(About the author)
 
     Align Blocks (or something else like cirlcles). use these macros : alignleft , alignright , aligncenter , aligntop , alignmiddle , alignbottom. useful sometimes ;)
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    ;**************************************
    ; Name: Aligning Blocks
    ; Description:Align Blocks (or something
    ;     else like cirlcles).
    use these macros : alignleft , alignright , aligncenter , aligntop , alignmiddle , alignbottom.
    useful sometimes ;)
    ; By: ali s
    ;
    ;This code is copyrighted and has    ; limited warranties.Please see http://w
    ;     ww.Planet-Source-Code.com/vb/scripts/Sho
    ;     wCode.asp?txtCodeId=66&lngWId;=13    ;for details.    ;**************************************
    
    (defun c:alignleft()
    	(setvar "CMDECHO" 0)
    	(setq ss(ssget))
    	(command "UNDO" "M")
    	(setq minx 0)
    	(setq first 1)
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		;(setq ct 0)
    	 		;(textpage)
    			;(repeat (length el)
    			;	(print (nth ct el)) ; Print a newline, then each list 
    			;	(setq ct (1+ ct)) ; Increments the counter by one.
    			;)
    	(setq pos (assoc 10 el))
    	 	(princ el)
    	 	(setq x (nth 1 pos))
    	 	(if (= first 1)
    		 	(progn
    			 (setq first 0)
    			 (setq minx x)
    		 	)
    	 		(setq minx (min minx x))
    		 )
    	 )
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		(setq pos (assoc 10 el))
    	 		(setq x (nth 1 pos))
    	 		(setq newpos (subst minx x pos))
    	 		(setq el (subst newpos pos el))
    	 		(entmod el)
    	 	;} end of modify 
    	 )
    (setq ss nil)
    (setq tmp nil)	 
    (setq el nil)
    (command "UNDO" "E")
    (setvar "CMDECHO" 1)
    (setvar "BLIPMODE" 1)
    (princ)
    )
    (defun c:alignright()
    	(setvar "CMDECHO" 0)
    	(setq ss(ssget))
    	(command "UNDO" "M")
    	(setq minx 0)
    	(setq first 1)
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		;(setq ct 0)
    	 		;(textpage)
    			;(repeat (length el)
    			;	(print (nth ct el)) ; Print a newline, then each list 
    			;	(setq ct (1+ ct)) ; Increments the counter by one.
    			;)
    	(setq pos (assoc 10 el))
    	 	(setq x (nth 1 pos))
    	 	(if (= first 1)
    		 	(progn
    			 (setq first 0)
    			 (setq minx x)
    		 	)
    	 		(setq minx (max minx x))
    		 )
    	 	;(princ (nth pos 2))
    	 	;} end of modify 
    	 )
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		(setq pos (assoc 10 el))
    	 		(setq x (nth 1 pos))
    	 		(setq newpos (subst minx x pos))
    	 		(setq el (subst newpos pos el))
    	 		(entmod el)
    	 	;} end of modify 
    	 )
    (setq ss nil)
    (setq tmp nil)	 
    (setq el nil)
    (command "UNDO" "E")
    (setvar "CMDECHO" 1)
    (setvar "BLIPMODE" 1)
    (princ)
    )
    (defun c:aligncenter()
    	(setvar "CMDECHO" 0)
    	(setq ss(ssget))
    	(command "UNDO" "M")
    	(setq avg 0)
    	(setq sum 0)
    	(setq first 1)
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		;(setq ct 0)
    	 		;(textpage)
    			;(repeat (length el)
    			;	(print (nth ct el)) ; Print a newline, then each list 
    			;	(setq ct (1+ ct)) ; Increments the counter by one.
    			;)
    	(setq pos (assoc 10 el))
    	 	(princ el)
    	 	(setq x (nth 1 pos))
    	 	(setq sum (+ sum x))
    	 )
    	(setq cnt (sslength ss))
    	(setq avg (/ sum cnt))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		(setq pos (assoc 10 el))
    	 		(setq x (nth 1 pos))
    	 		(setq newpos (subst avg x pos))
    	 		(setq el (subst newpos pos el))
    	 		(entmod el)
    	 	;} end of modify 
    	 )
    (setq ss nil)
    (setq tmp nil)	 
    (setq el nil)
    (command "UNDO" "E")
    (setvar "CMDECHO" 1)
    (setvar "BLIPMODE" 1)
    (princ)
    )
    (defun c:alignbottom()
    	(setvar "CMDECHO" 0)
    	(setq ss(ssget))
    	(command "UNDO" "M")
    	(setq minx 0)
    	(setq first 1)
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		;(setq ct 0)
    	 		;(textpage)
    			;(repeat (length el)
    			;	(print (nth ct el)) ; Print a newline, then each list 
    			;	(setq ct (1+ ct)) ; Increments the counter by one.
    			;)
    	(setq pos (assoc 10 el))
    	 	(princ el)
    	 	(setq x (nth 2 pos))
    	 	(if (= first 1)
    		 	(progn
    			 (setq first 0)
    			 (setq minx x)
    		 	)
    	 		(setq minx (min minx x))
    		 )
    	 )
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		(setq pos (assoc 10 el))
    	 		(setq x (nth 2 pos))
    	 		(setq newpos (subst minx x pos))
    	 		(setq el (subst newpos pos el))
    	 		(entmod el)
    	 	;} end of modify 
    	 )
    (setq ss nil)
    (setq tmp nil)	 
    (setq el nil)
    (command "UNDO" "E")
    (setvar "CMDECHO" 1)
    (setvar "BLIPMODE" 1)
    (princ)
    )
    (defun c:aligntop()
    	(setvar "CMDECHO" 0)
    	(setq ss(ssget))
    	(command "UNDO" "M")
    	(setq minx 0)
    	(setq first 1)
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		;(setq ct 0)
    	 		;(textpage)
    			;(repeat (length el)
    			;	(print (nth ct el)) ; Print a newline, then each list 
    			;	(setq ct (1+ ct)) ; Increments the counter by one.
    			;)
    	(setq pos (assoc 10 el))
    	 	(setq x (nth 2 pos))
    	 	(if (= first 1)
    		 	(progn
    			 (setq first 0)
    			 (setq minx x)
    		 	)
    	 		(setq minx (max minx x))
    		 )
    	 	;(princ (nth pos 2))
    	 	;} end of modify 
    	 )
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		(setq pos (assoc 10 el))
    	 		(setq x (nth 2 pos))
    	 		(setq newpos (subst minx x pos))
    	 		(setq el (subst newpos pos el))
    	 		(entmod el)
    	 	;} end of modify 
    	 )
    (setq ss nil)
    (setq tmp nil)	 
    (setq el nil)
    (command "UNDO" "E")
    (setvar "CMDECHO" 1)
    (setvar "BLIPMODE" 1)
    (princ)
    )
    (defun c:alignmiddle()
    	(setvar "CMDECHO" 0)
    	(setq ss(ssget))
    	(command "UNDO" "M")
    	(setq avg 0)
    	(setq sum 0)
    	(setq first 1)
    	(setq cnt (sslength ss))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		;(setq ct 0)
    	 		;(textpage)
    			;(repeat (length el)
    			;	(print (nth ct el)) ; Print a newline, then each list 
    			;	(setq ct (1+ ct)) ; Increments the counter by one.
    			;)
    	(setq pos (assoc 10 el))
    	 	(princ el)
    	 	(setq x (nth 2 pos))
    	 	(setq sum (+ sum x))
    	 )
    	(setq cnt (sslength ss))
    	(setq avg (/ sum cnt))
    	(while (>= (setq cnt (1- cnt)) 0)
    	 	(setq tmp (ssname ss cnt))
    	 	(setq el (entget tmp))
    	 	;{ modify the current el
    	 		(setq pos (assoc 10 el))
    	 		(setq x (nth 2 pos))
    	 		(setq newpos (subst avg x pos))
    	 		(setq el (subst newpos pos el))
    	 		(entmod el)
    	 	;} end of modify 
    	 )
    (setq ss nil)
    (setq tmp nil)	 
    (setq el nil)
    (command "UNDO" "E")
    (setvar "CMDECHO" 1)
    (setvar "BLIPMODE" 1)
    (princ)
    )

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | LISP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.