scale command in autolisp routin

scale command in autolisp routin

aliozcicek
Contributor Contributor
2,456 Views
2 Replies
Message 1 of 3

scale command in autolisp routin

aliozcicek
Contributor
Contributor

Hi everyone,

 

I am trying to writing code which will help me to scale all line or polyline object from their midpoint by "3". 

 

....

(setq sec (ssget "_WP" (list PT1 PT2 PT3 PT4) (list (cons 0 tl1) (cons 8 tl2))))
(setq sca (getdist"\scale faktör giriniz !")); scale factor
(setq bas 0)
(setq cizgisay (sslength sec))
(setq çizgi1 (ssname sec bas)); first line object entity name
(setq k1 (entget çizgi1)) 
(setq n1 (assoc 10 k1))
(if (assoc 11 k1) (setq n2 (assoc 11 k1)) (setq n2 (assoc 10 (reverse k1))))
(setq n1s (list (nth 1 n1) (nth 2 n1)))
(setq n2s (list (nth 1 n2) (nth 2 n2)))
(setq ang1 (angle n1s n2s))
(setq gn1 (polar n1s ang1 (/ (distance n1s n2s) 2))); midpoint of object
(command ".scale" çizgi1 "" gn1 "3")

 

but command ending with "nil"

 

can anyone helpt me to solve?

0 Likes
Accepted solutions (1)
2,457 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant

@aliozcicek wrote:

.... command ending with "nil"

....


Does it Scale things as you want?  If so, don't worry about the nil return at the end -- the (command) function always returns nil  [read about it in Help].  You can suppress that nil return by ending the routine with a:

 

(princ)

 

function with no arguments, which "exits quietly" [read about that, too, also (print) and (prin1)] -- you will see that at the end of many  AutoLisp routines on this Forum.

 

You may be interested in my routine to Scale multiple objects [of all types, not just Lines and Polylines] about each one's center/middle, ScaleAboutCenters.lsp with its SAC command, available >>here<< or at >>this Post<<.  It uses the midpoint of each object's bounding box, so in the case of a Polyline that is not just a single line segment, the base point it finds will sometimes be different from yours, which uses the point half-way between the start and end vertices.

Kent Cooper, AIA
0 Likes
Message 3 of 3

aliozcicek
Contributor
Contributor
Accepted solution

soryy all... I just understand what my command works but I couldn't see result. my fault. 

 

Kent Cooper thanks for your advice and help.  I think it is better to solve my routin first to improve myself. ;). But anyway I check your lispt too... 

 

thanks all...

 

0 Likes