AutoLisp Examples - Requested Programs PDF
AutoLisp Examples - Requested Programs PDF
AutoLisp Examples - Requested Programs PDF
CopyC.lsp - Wendy Diffendall, the Senior CAD Drafter at Facilities Planners + Architects in Harrisb
PA. wanted a program to do multiple Copies with preset defaults.
GetArea.lsp - Jamey Westmoreland, a Civil Engineer E.I.T. for Toothman-Orton Engineering Co. in
ID wanted a program to label the accumulated area of selected polyline entities.
GetAcre.lsp - Bruce Stanton wanted a program to label each polyline entity with the area in square fe
and acreage.
DLD.lsp - An anonymous visitor wanted a program to draw a vertical line next to multiple lines of tex
during a Dim Leader command. Sounds easy right? Yeesh!
LTR.lsp - Jamey Westmoreland, a Civil Engineer E.I.T. for Toothman-Orton Engineering Co. in Boi
wanted a program to select a Line entity, a Text entity, then rotate the text entity based on the angle o line.
TXTCNT.lsp - An anonymous visitor wanted a program to count how many times each text entity
appeared in a drawing and display the results sorted in a dialog box.
TEXTIN.lsp - A program to read from a text file and write to an AutoCAD drawing. TEXTOUT.lsp - A program to read from an AutoCAD drawing and write to a text file. Support this Site!
A U T O L I S P
CopyC.lsp
program to make the Copy command continuous. Ask for a distance, ask for an angle, set them as defaults, then Copy Continuously. [ The Copy, Array and Offset commands were not cutting it!] ; C o p y C . l s p-C o p yC o n t i n u o u s ( d e f u nC : C C ( ) ; t u r no f ft h es y s t e me c h o ( s e t v a r" c m d e c h o "0 ) ; s e tt h ee x i tn o t et ob es u c c e s s f u l ( s e t qe r n o t e" \ n. . . C C . l s pC o m p l e t e ! " ) ; g e tas e l e c t i o ns e t ( i f ( s e t qe s e t ( s s g e t ) ) ( p r o g n
Wendy Diffendall, the Senior CAD Drafter at Facilities Planners + Architects in Harrisburg, PA. wan
A U T O
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
8/14/13
O L I S P
; w h i l et h eu s e rd o e sn o tw a n tt oe x i t ( w h i l e ( / =a n s" X " )
d i s ) ) )
A U T O L I S P
a w a y
) ; i ft h eu s e rp r e s s e se n t e rt h e n ( i f ( =a n s" " ) ( p r o g n
2 4 "f r o m o r i g i n a l a d d e dt o
; t h e[ a c u D i s ]v a r i a b l eh o l d st h i sd i s t a n c e .I tg e t s[ d i s ] ; i te a c hl o o p . ( s e t qa c u D i s ( +a c u D i sd i s ) ) )
A U T O L I S P
t h e
; i ft h eu s e rp r e s s e sXt oe x i to rt y p e st h ew o r dE X I Tt h e ns e ; [ a n s ]v a r i a b l et oe q u a l" X " .T h ep r o g r a mw i l le x i t . ( i f ( =a n s" E X I T " ) ( s e t qa n s" X " ) ) ; i ft h eu s e rw a n t st oc h a n g et h ea n g l e .[ a n g ] ( i f ( o r ( =a n s" A N G L E " ) ( =a n s" A " ) ) ( w h i l e ( n o t ( s e t qa n g ( g e t a n g l e( g e t v a r" v i e w c t r " )" \ nA n g l e : )
" ) ) ) )
" ) ) ) )
A U T O L
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
8/14/13
L I S P
GetArea.lsp
Jamey Westmoreland, a Civil Engineer E.I.T. for Toothman-Orton Engineering Co. in Boise ID wante program to label the accumulated area of selected polyline entities. ; G e t A r e a . l s p-T o t a lt h ea r e a so fs e l e c t e dp o l y l i n ee n t i t i e s . ; W a r n i n g . . . . T h i sw i l la l s or e t u r na na r e af o ra ne n t i t yt h a ti sn o t e n c l o s e d . ( d e f u nC : G e t A r e a ( ) ; t u r no f ft h es y s t e me c h o ( s e t v a r" c m d e c h o "0 ) ; s e tu pav a r i a b l et oh o l dt h ea c c u m u l a t e da r e a s ( s e t qm y A r e a0 )
A U T O L I S P
; w h i l et h eu s e rk e e p sm a k i n gas e l e c t i o n ( w h i l e ( s e t qe n t ( e n t s e l ) ) ; i fa ne n t i t yw a ss e l e c t e da n dn o tap o i n ti ns p a c e ( i f ( c a re n t ) ( p r o g n
; l e tA u t o C A Dg e tt h ea r e ao ft h eo b j e c t . . . c h e a py e te f f e c t i v w a yo u t . ; N o t e :A u t o C A Ds t o r e st h ea r e ai nt h es y s t e mv a r i a b l e" A r e a " ( c o m m a n d" a r e a "" O b j e c t "( c a re n t ) ) ; p r i n tt h ea r e at ot h ec o m m a n dl i n e ( p r i n c " A r e a " ) ) ) ) ; a c c u m u l a t et h ea r e ai fi te x i s t ( i f( g e t v a r" A r e a " ) ( s e t qm y A r e a ( +m y A r e a( g e t v a r" A r e a " ) ) ) ) ( s t r c a t" \ nT o t a lA r e af o rt h i sO b j e c t="( r t o s( g e t v a r
; a s kf o rat e x ti n s e r t i o np o i n t ( s e t qp t 1 ( g e t p o i n t" \ nI n s e r t i o nP o i n t :" ) ) ; p r i n tt h ea r e ai nt h ed r a w i n g ( c o m m a n d" t e x t "p t 1" "" "( s t r c a t" T o t a lA r e a :"( r t o sm y A r e a ) ) ) ; p r i n tt h ee x i tm e s s a g et ot h ec o m m a n dl i n e ( p r i n c" \ n. . . G e t A r e a . l s pC o m p l e t e .\ n" ) ; s u p p r e s st h el a s te c h o ( p r i n c ) ) ; e n do fp r o g r a m Download this file: Click Here!
A U T O L I S P
GetAcre.lsp
Bruce Stanton wanted a program similar to the one above. Except, he wanted to label each polyline e with the area in square feet and acreage. ; G e t A c r e . l s p-G e tt h ea r e ao fas e l e c t e dp o l y l i n ee n t i t y . ; W a r n i n g . . . . T h i sw i l la l s or e t u r na na r e af o ra ne n t i t yt h a ti sn o t e n c l o s e d . ( d e f u nC : G A ( ) ; t u r nt h es y s t e me c h oo f f ( s e t v a r" c m d e c h o "0 )
A U
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
8/14/13
T O L I S P
; i fa no b j e c tw a ss e l e c t e da n dn o ts o m ep o i n ti ns p a c e ( i f( c a re n t ) ( p r o g n
; g e tA u t o C A Dt of i n dt h ea r e ao ft h ep o l y l i n e ,c h e a py e te f f e c t w a yo u t ; N o t e :A u t o C A Ds t o r e st h ei n f o r m a t i o ni nt h es y s t e mv a r i a b l e " A r e a " ( c o m m a n d" a r e a "" O b j e c t "( c a re n t ) ) ; g e tt h ea r e af r o mt h es y s t e mv a r i a b l e" A r e a "a n dc o n v e r tf r o m ; s q u a r ei n c h e st os q u a r ef e e t ( s e t qm y a r e a( / ( g e t v a r" A r e a " ) 1 4 4 . 0 ) ) ; p r i n tt h es qf e e tt ot h ec o m m a n dl i n e ( p r i n c" \ nT o t a lS q u a r eF e e t:" ) ( p r i n c( r t o sm y A r e a ) ) ; p r i n tt h ea c r e a g et ot h ec o m m a n dl i n ea f t e rc o n v e r t i n g ( p r i n c" \ nT o t a lA c r e a g e:" ) ( p r i n c( r t o s( /m y A r e a4 3 5 6 0 . 0 ) ) )
A U T O L I S P
) ; c l o s et h ei fp r o g nf o rp o i n ts e l e c t i o n ) ) ; c l o s et h ei f ; c l o s et h ei fp r o g nf o ro b j e c ts e l e c t i o n
A
Related Searches: POP Accounts Gmail Filters Txt File Text Encryption Software Native POP3 Connector
; c l o s et h ei fs t a t e m e n t
U T O L I S P
)
; p r i n tt h ee x i tn o t et ot h ec o m m a n dl i n e ( p r i n ce r n o t e ) ; r e s e tt h es y s t e me c h ov a r i a b l e ( s e t v a r" c m d e c h o "1 ) ; s u p p r e s st h el a s te c h o ( p r i n c )
DLD.lsp
Visitor wanted a program that would draw a vertical line next to multiple lines of text during a Dim Le command. Sounds simple right? Yeesh! ; D L D . l s p-D r a wav e r t i c a ll i n en e x tt om u l t i p l el i n e so f ; t e x td u r i n gad i ml e a d e rc o m m a n d . ( d e f u nC : D L D ( ) ; t u r ns y s t e me c h oo f f ( s e t v a r" c m d e c h o "0 ) ; g e tt h es t a r tp o i n to ft h el e a d e rl i n e ( s e t qp t 1 ( g e t p o i n t" \ nS t a r tP o i n t :" ) )
A U
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
; s e t u ps o m ev a r i a b l e st ob eu s e dl a t e r ; [ t p 1 ]i sat e m p o r a r yp o i n t ; [ c n t r ]i sac o u n t e r ; [ t h t ]h o l d st h ec u r r e n tt e x ts i z e
4/11
8/14/13
U T O L I
; u n r e m a r kt h en e x tl i n ea n dr e p l a c eY O U R _ L A Y E R _ N A M Ew i t hy o u rl a y e r n a m e , ; t h i sw o u l db et h el a y e rn a m ef o ry o u rl e a d e rl i n e sa n da r r o wh e a d . ; I fy o ua r eu s i n gav e r s i o no fa u t o c a da b o v e1 4y o um i g h th a v et o r e p l a c e ; " l a y e r "w i t h" l a y e r "o rp e r h a p s" _ l a y e r " .Y o uc o u l dw r i t eaf u n c t i ; t oc h e c kt h ev e r s i o no fa u t o c a da n dd e c i d ew h i c ht ou s ea tt h a tp o i ; ( c o m m a n d" l a y e r "" s e t "" Y O U R _ L A Y E R _ N A M E "" " ) ; l o o pu n t i lt h eu s e rq u i t ss e l e c t i n gp o i n t s ( w h i l e( / =n i l ( s e t qt p t ( g e t p o i n t t p t " \ nN e x tP o i n t :" ) ) ) Trust Rating ; i fi ti st h ef i r s tp o i n tt h eu s e rh a ss e l e c t e d jefferypsanders.com ( i f ( =c n t r0 )
Not Yet Rated
WebCake Ads
S P A U T O L I S P
A U T O L I S P
; u n r e m a r kt h en e x tl i n ea n dr e p l a c eY O U R _ L A Y E R _ N A M Ew i t hy o u rl a y n a m e . ; t h i sw o u l db et h el a y e rn a m ef o ry o u rt e x t .I fy o ua r eu s i n ga v e r s i o n ; o fa u t o c a da b o v e1 4y o um i g h th a v et or e p l a c e" l a y e r "w i t h o r ; p e r h a p s" _ l a y e r " .Y o uc o u l dw r i t eaf u n c t i o nt oc h e c kt h ev e r s i o o f ; a u t o c a da n dd e c i d ew h i c ht ou s ea tt h a tp o i n t . ; ( c o m m a n d" l a y e r "" s e t "" Y O U R _ L A Y E R _ N A M E "" " ) ; c h e c kt h el a s tl i n ea n g l et od e c i d ew h e t h e rt h et e x t ; s h o u l db eL e f to rR i g h tJ u s t i f i e d . ( i f ( o r ( <a n g l( /p i0 . 5 ) ) ( >a n g l( *p i1 . 5 ) ) ) ; l e f tj u s t i f i e d ( c o m m a n d" t e x t "" j "" M L "t x p t" "0s t r ) ; r i g h tj u s t i f i e d ( c o m m a n d" t e x t "" j "" M R "t x p t" "0s t r )
; u n r e m a r kt h en e x tl i n ea n dr e p l a c eY O U R _ L A Y E R _ N A M Ew i t hy o u rl a y n a m e . ; t h i sw o u l db et h el a y e rn a m ef o rt h ev e r t i c a ll i n en e x tt ot h e t e x t . ; I fy o ua r eu s i n gav e r s i o no fa u t o c a da b o v e1 4y o um i g h th a v et o r e p l a c e ; " l a y e r "w i t h" l a y e r "o rp e r h a p s" _ l a y e r " .Y o uc o u l dw r i t ea f u n c t i o n ; t oc h e c kt h ev e r s i o no fa u t o c a da n dd e c i d ew h i c ht ou s ea tt h a t p o i n t . ; ( c o m m a n d" l a y e r "" s e t "" Y O U R _ L A Y E R _ N A M E "" " ) ; d r a wt h ev e r t i c a ll i n e ( c o m m a n d" l i n e " ( p o l a ro l d p t( *p i0 . 5 )( /t h t2 . 0 ) ) ( p o l a ro l d p t( *p i1 . 5 )( +( /t h t2 . 0 ) ( *t h t0 . 2 5 ) ) ) " "
5/11
A U T
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
8/14/13
O L I S P
)
) ; r e s e tt h et e x ts t a r t i n gl o c a t i o nd o w nal i n e ( s e t qt x p t( p o l a rt x p t( *p i1 . 5 )( +t h t ( *t h t0 . 2 5 ) ) ) ) ; r e s e tt h el o c a t i o no ft h en e x tv e r t i c a ll i n e ( s e t qo l d p t ( p o l a ro l d p t( *p i1 . 5 )( +t h t ( *t h t0 . 2 5 ) ) ) )
A U T O L I S P
LTR.lsp
Jamey Westmoreland, a Civil Engineer E.I.T. for Toothman-Orton Engineering Co. in Boise ID want program to select a Line entity, a Text entity, then rotate the text entity based on the angle of the line. ; L T R . l s p-s e l e c taL i n ee n t i t ya n daT e x te n t i t yt h e nr o t a t et h e e n t i t yb a s e do nl i n ea n g l e . ( d e f u nC : L T R ( ) ; t u r no f ft h es y s t e me c h o ( s e t v a r" c m d e c h o "0 ) ; d i s p l a yam e s s a g eo nt h ec o m m a n dl i n e ( p r i n c" \ nS e l e c tL I N Ew i t hC o r r e c tA n g l e . " ) ; l e tt h eu s e rs e l e c to n ee n t i t y ( i f( s e t qe s e t ( e n t s e l ) ) ( p r o g n ; g e tt h ee n t i t yn a m ef r o mt h ee n t s e lc o m m a n d ( s e t qe n ( c a re s e t ) ) ; g e tt h eD X Fg r o u pc o d e so ft h es e l e c t e de n t i t y ( s e t qe n l i s t ( e n t g e te n ) )
A U T O L I S P
A U
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
; u p d a t et h et e x te n t i t y ( e n t m o de n l i s t 2 )
8/14/13
T O L I S P A U T O L I S P
TXTCNT.lsp
Visitor wanted a program to count how many times each text entity appeared in a drawing and display results sorted in a dialog box. ; T X T C N T . l s p-C o u n th o wm a n yt i m e se a c ht e x te n t i t ya p p e a r s . ;D i s p l a yt h er e s u l t ss o r t e di nad i a l o gb o x .
( d e f u nC : T X T C N T ( )
; d e f i n eas o r tr o u t i n e-U s a g e :( s r tl i s t )-L e t ' sn o tg oi n t ot h i sy e t !I tw o r k s . ( d e f u ns r t ( a l i s t/n ) ( s e t ql c u pn i lr c u pn i l ) ( d e f u nc t s ( ab ) ( c o n d ( ( >ab ) t ) ( ( =ab) t ) ( tn i l ) ) ) ( f o r e a c hna l i s t ( w h i l e( a n dr c u p ( c t sn ( c a rr c u p ) ) ) ( s e t ql c u p ( c o n s ( c a rr c u p ) l c u p ) r c u p ( c d rr c u p ) ) ) ( w h i l e( a n dl c u p ( c t s ( c a rl c u p ) n ) ) ( s e t qr c u p ( c o n s ( c a rl c u p ) r c u p ) l c u p ( c d rl c u p ) ) ) ( s e t qr c u p ( c o n snr c u p ) ) ) ( a p p e n d ( r e v e r s el c u p ) r c u p ) ) ; t u r nt h ec o m m a n de c h oo f f ( s e t v a r" c m d e c h o "0 ) ; s e t u pav a r i a b l et oh o l dt h ed a t a ( s e t qd a t a l i s t ( l i s t ) ) ; s e l e c to b j e c t s ( i f( s e t qe s e t ( s s g e t ) ) ( p r o g n ; s e tac o u n t e rt ot h ef i r s ti t e mi nt h es e l e c t i o ns e t ( s e t qc n t r0 ) ; l o o pt h r o u g he a c hs e l e c t e de n t i t y ( w h i l e( <c n t r( s s l e n g t he s e t ) ) ; g r a bt h ee n t i t y ' sn a m e ( s e t qe n ( s s n a m ee s e tc n t r ) ) ; g r a bt h eD X Fg r o u pc o d e so ft h ee n t i t y ( s e t qe n l i s t ( e n t g e te n ) )
; g e tt h et e x tv a l u ef r o mt h eD X FG r o u pC o d e ( s e t qs t r ( c d r ( a s s o c1e n l i s t ) ) ) ; s e t u pav a r i a b l et oc h e c ki ft h ee n t i t ye x i s ti nt h ed a t a l i s tl i s t ( s e t qe x i s t i n g0 )
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
7/11
8/14/13
; r e a r r a n g et h el i s t ( f o r e a c had a t a l i s t ( s e t qn e w L i s t ( a p p e n dn e w L i s t ( l i s t ( s t r c a t ( s u b s t r ( s t r c a t( c a ra )".........................." ) 15 0 ) "-"( i t o a ( c d ra ) ) ) ) ) ) ) ; s o r tt h el i s t ( s e t qn e w L i s t ( s r tn e w L i s t ) ) ; p u tu pt h ed i a l o gb o x ( s e t qd c l _ i d( l o a d _ d i a l o g" T X T C N T . d c l " ) ) ; s e ei fi ti sa l r e a d yl o a d e d ( i f( n o t( n e w _ d i a l o g" T X T C N T "d c l _ i d ))( e x i t ) ) ; a d dt h ed a t at ot h el i s ti nt h ed i a l o gb o x ( s t a r t _ l i s t" d a t a l i s t " ) ( m a p c a r'a d d _ l i s tn e w L i s t ) ( e n d _ l i s t ) ; i fa na c t i o ne v e n to c c u r s ,d ot h i sf u n c t i o n ( a c t i o n _ t i l e" c a n c e l "" ( s e t qd d i a g1 ) ( d o n e _ d i a l o g ) " ) ; d i s p l a yt h ed i a l o gb o x ( s t a r t _ d i a l o g ) ; i ft h ec a n c e lb u t t o nw a sp r e s s e d-d i s p l a ym e s s a g e ( i f( =d d i a g1 ) ( p r i n c" \ n\ n. . . T X T C N TC a n c e l l e d .\ n" ) ) ; u n l o a dt h ed i a l o gb o x ( u n l o a d _ d i a l o gd c l _ i d ) ; t u r nt h ec o m m a n de c h ob a c ko n ( s e t v a r" c m d e c h o "1 ) ; s u p r e s st h el a s te c h o ( p r i n c ) ) ; E n do fA u t o L i s pP r o g r a m
8/14/13
AutoLisp Examples - Requested Programs :b o x e d _ r o w{ :b u t t o n{ k e y=" c a n c e l " ; l a b e l="C a n c e l" ; i s _ d e f a u l t=f a l s e ; i s _ c a n c e l=t r u e ; } } }
E n do fD C LF i l e
Download this AutoLisp file: Click Here! Download this DCL file: Click Here!
TextIn.lsp
Read Text From a File, Write Text in the AutoCAD Drawing
; T E X T I N . L S PB y :J e f f e r yP .S a n d e r s ; T h i sp r o g r a mt a k e sa n yt e x tf i l ea n dp r i n t si ti nA u t o C A D . ; d e f i n ep r o g r a m-l i s t i n gy o u rv a r i a b l en a m e sh e r e ;r e s e t st h e mt on i la f t e rt h ep r o g r a mf i n i s h e s ( d e f u nC : T E X T I N ( /l t se r n o t ei n s p tf i l e nf i ll i n e o n e ) ; t u r ne c h oo f f ( s e t v a r" c m d e c h o "0 ) ; g e tl t s c a l e( N o t e :l t s c a l es h o u l da l w a y se q u a ld i m s c a l e ) ( s e t ql t s ( g e t v a r" l t s c a l e " ) ) ; s e tt h ee x i tn o t et od i s p l a ys u c c e s s f u l ( s e t qe r n o t e" \ n . . . . T e x t I nC o m p l e t e . " ) ; g e tt h et e x ti n s e r t i o np o i n t ( s e t qi n s p t ( g e t p o i n t" \ n I n s e r t i o nP o i n t :" ) ) ; u s ed i a l o gb o xt og e tf i l en a m e/t h e4a l l o w s ; t h eu s e rt ot y p ei nan e wf i l ee x t e n s i o n ; t h e" t x t "s e t st h ed e f a u l tt ob e" * . t x t " ( s e t qf i l e n ( g e t f i l e d" S e l e c tT e x tF i l e "" "" t x t "4 ) ) ; i ff i l ee x i s t ,o p e nf i l et or e a d ( i f( s e t qf i l ( o p e nf i l e n" r " ) ) ; p r o g nn e c e s s a r yf o rm u l t i p l es t a t e m e n t si n s i d ei fs t a t e m e n t ( p r o g n ; w h i l et h el i n ef r o mt e x tf i l ed o e sn o te q u a ln i l ( w h i l e( s e t ql i n e o n e ( r e a d l i n ef i l ) ) ; p r i n tt h et e x ti nA u t o C A Dd r a w i n g ( c o m m a n d" t e x t "i n s p t ( *l t s ( g e t v a r" t e x t s i z e " ) ) 0 . 0l i n e o n e ) ; m o v ed o w no n el i n ee a c hl o o pb yr e s e t t i n gt h ei n s e r t i o np o i n t ( s e t qi n s p t ; s t a r tt h ep o l a rf u n c t i o ni . e .[ p o l a rp ta n g l ed i s t a n c e ] ( p o l a r ; f r o mt h ei n s e r t i o np o i n t i n s p t ; s e tt h ea n g l et og od o w ni . e .( 2 7 0d e gO Rp i+p i / 2r a d i a n s ) ( *p i1 . 5 ) ; d i s t a n c ed o w nt ot h en e x tl i n ei s( t e x t s i z ex1 . 5 )xl t s c a l e ( *l t s( *1 . 5 ( g e t v a r" t e x t s i z e " ) ) ) );c l o s et h ep o l a rf u n c t i o n );c l o s et h es e t q );c l o s et h ew h i l el o o p ; c l o s et h et e x tf i l e ( c l o s ef i l ) );c l o s et h ei fp r o g ns t a t e m e n t ; e l s es e tt h ee x i t i n gr e m a r ka sa ne r r o r ( s e t qe r n o t e( s t r c a t" \ n C a n n o tF i n dF i l e :"f i l e n ) ) );c l o s et h ei fs t a t e m e n t
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
9/11
8/14/13
TextOut.lsp
Read Text From an AutoCAD Drawing, Write the Text To a File
; T E X T O U T . L S PB y :J e f f e r yP .S a n d e r s ; T h i sp r o g r a mg e t st e x tf r o ma nA u t o C A Dd r a w i n ga n dw r i t e si tt oat e x tf i l e . ; d e f i n ep r o g r a m-l i s t i n gy o u rv a r i a b l en a m e sh e r e ;r e s e t st h e mt on i la f t e rt h ep r o g r a mf i n i s h e s ( d e f u nC : T E X T O U T ( /l t se r n o t ef i l e nf i le s e te ne n l i s tc n t r ) ; t u r ne c h oo f f ( s e t v a r" c m d e c h o "0 ) ; g e tl t s c a l e( N o t e :l t s c a l es h o u l da l w a y se q u a ld i m s c a l e ) ( s e t ql t s ( g e t v a r" l t s c a l e " ) ) ; s e tt h ee x i tn o t et os u c c e s s f u l ( s e t qe r n o t e" \ n . . . . T e x t O u tC o m p l e t e . " ) ; u s ed i a l o gb o xt os e tf i l en a m e/t h e1a l l o w s ; t h eu s e rt ot y p ei nan e wf i l en a m e ; t h e" t x t "s e t st h ed e f a u l tt ob e" * . t x t " ( s e t qf i l e n ( g e t f i l e d" T y p eo rS e l e c tT e x tF i l eN a m e "" "" t x t "1 ) ) ; o p e nf i l et ow r i t e ( i f( s e t qf i l ( o p e nf i l e n" w " ) ) ; p r o g nn e c e s s a r yf o rm u l t i p l es t a t e m e n t si n s i d ea ni fs t a t e m e n t ( p r o g n ; i fs s g e tr e t u r n sav a l i ds e l e c t i o ns e t ( i f( s e t qe s e t ( s s g e t ) ) ; p r o g nn e c e s s a r yf o rm u l t i p l es t a t e m e n t si n s i d ea ni fs t a t e m e n t ( p r o g n ; s e tt h ee n t i t yc o u n t e rt oz e r o[ t h ef i r s te n t i t yi nas e ti sz e r o ] ( s e t qc n t r0 ) ; s t e pt h r o u g he a c he n t i t yi nt h es e l e c t i o ns e t ( w h i l e( <c n t r( s s l e n g t he s e t ) ) ; g e tt h ee n t i t yn a m ei n d e x e db yc n t r ( s e t qe n ( s s n a m ee s e tc n t r ) ) ; g e tt h eD X Fg r o u pc o d e sf o rt h ee n t i t y ( s e t qe n l i s t ( e n t g e te n ) ) ; c h e c kt h eg r o u pc o d e0t os e ei fe n t i t yt y p e=T E X T ( i f ( =" T E X T "( c d r ( a s s o c0e n l i s t ) ) ) ; p r o g nn e c e s s a r yf o rm u l t i p l es t a t e m e n t si n s i d ea ni fs t a t e m e n t ( p r o g n ; g e tt h et e x ts t r i n gf r o mt h ee n t i t y ' sD X FG r o u pC o d e1 ( s e t qs t r ( c d r ( a s s o c1e n l i s t ) ) ) ; p r i n tt h es t r i n gt ot h ec o m m a n dl i n e ( p r i n c( s t r c a t" \ n O u t p u tT oF i l e :"s t r ) ) ; p r i n tt h es t r i n gt ot h ef i l e ( p r i n c( s t r c a t" \ n "s t r )f i l ) ); c l o s et h ei fp r o g n ); c l o s et h ei fs t a t e m e n t ; i n c r e m e n tt h ec o u n t e rt og e tt h en e x te n t i t y ( s e t qc n t r ( +c n t r1 ) ) ); c l o s et h ew h i l el o o p ; c l o s et h et e x tf i l e ( c l o s ef i l ) ); c l o s et h ei fp r o g n ; s e tt h ee x i tn o t ea sa ne r r o r
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
10/11
8/14/13
New! Having trouble with one of the programs not working for your version of AutoCAD? Click this-----> Please fix this!
AutoLisp Home Home All questions/complaints/suggestions should be sent to JefferyPSanders.com Last Updated April 1st, 2013 Copyright 2002-2013 JefferyPSanders.com. All rights reserved.
www.jefferypsanders.com/autolisp_examp.html#GetArea.lsp
11/11