Change Circle Diameter

Change Circle Diameter

SilentStrike24
Enthusiast Enthusiast
715 Views
8 Replies
Message 1 of 9

Change Circle Diameter

SilentStrike24
Enthusiast
Enthusiast

Hi guys!

 

Please help me with a small issue regarding circles.

 

Is there any routine that can change circle diameter by a specified factor? I have lots of circles that need to be 80% smaller than they are now. So, in principle, routine should ask me for a decreasing factor and then to select circles one by one.

 

Any hints will be appreciated!

 

Cheers!

Accepted solutions (1)
716 Views
8 Replies
Replies (8)
Message 2 of 9

hak_vz
Advisor
Advisor

Try this

 

 

(defun c:scale_circle(/ f e eo *error*)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
	)
	(setq f (getreal "\nEnter circle scaling factor > "))
	(while (setq e (car(entsel "\Select circle to scale > ")))
	(setq eo (vlax-ename->vla-object e))
	(vlax-put eo 'Diameter (* f (vlax-get eo 'Diameter)))
	)
	(princ)
)

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 9

SilentStrike24
Enthusiast
Enthusiast

Thanks for the answer @hak_vz !

 

I tried the routine, but unfortunately it appears it's not working properly. After i write the factor and select the circle it does nothing, it just exits.

0 Likes
Message 4 of 9

hak_vz
Advisor
Advisor
Accepted solution

Try this instead

(defun c:scale_circle(/ f e ent new_rad *error*)
	(defun *error* ( msg )
		(if (not (member msg '("Function cancelled" "quit / exit abort")))
			(princ)
		)
	)
	(setq f (getreal "\nEnter circle scaling factor > "))
	(while (setq e (car(entsel "\Select circle to scale > ")))
	(setq ent (entget e))
	(setq new_rad (* f (cdr (assoc 40 ent))))
	(setq ent (subst (cons 40 new_rad) (assoc 40 ent) ent))
	(entmod ent)
	)
	(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 9

SilentStrike24
Enthusiast
Enthusiast

Yes, this works perfect, @hak_vz!

 

Thank you so much and wish you a great day!

0 Likes
Message 6 of 9

hak_vz
Advisor
Advisor

Glad to be of help.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 9

SilentStrike24
Enthusiast
Enthusiast

@hak_vz i just did 🙂

 

Thanks again!

 

I'm embarrassed of asking for your help again, but i have another post still without any solution. If you can take a look there i'll be grateful🙏

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/search-text-string/td-p/10508036

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant

@SilentStrike24 wrote:

....

Is there any routine that can change circle diameter by a specified factor? .... routine should ask me for a decreasing factor and then to select circles one by one.

....


[It may be moot now, but @hak_vz's first version worked for me.]

 

Attached is CircleScaleFactor.lsp with the CSF command.  It has some snazzy features I brought in from other routines.

 

After the first use, it remembers your chosen scale factor [which doesn't need to be decreasing, but can be larger than 1, and it won't allow 0 or a negative number], and offers it as the default on subsequent use.

 

If you pick something other than a Circle, or one on a locked Layer, or simply miss, it asks again.  Enter/space/ESCape exits the command.

 

It has an internal Undo-one-at-a-time option, so if you pick on one you didn't mean to scale, or accidentally pick the same one twice, you can revert just the latest one without affecting others you've scaled in the same running of the command.  You can step back one at a time, reverting the scalings in reverse order, until you reach the first one [when it stops offering the Undo option].  After completing the command, if you use U, it reverts all the changes made within that running of it.

Kent Cooper, AIA
Message 9 of 9

SilentStrike24
Enthusiast
Enthusiast

Awesome, @Kent1Cooper ! Works like a charm!

 

Thank you very much for sharing!🙏

0 Likes