Jump to content

Autocad Lisp For Scaling Down/up From Center


onzki

Recommended Posts

Hi guys, can you help me find lisp for the following procedure:

 

1. scale down an object by 50%

note: scale reference point must be object's center (since my object is circle)

 

that's it:)

 

Thanks a lot!:D

Link to comment
Share on other sites

Probably, because your procedure is really really basic, and can be done easily manually, no-one has thought to write a lisp for it :cry:

Link to comment
Share on other sites

Couldn't resist the VL route:

 

(defun c:scl (/ ent Obj)
 (vl-load-com)
 (while
   (and
     (setq ent (car (entsel "\nSelect Object: ")))
     (vlax-property-available-p
       (setq Obj
         (vlax-ename->vla-object ent)) 'Center))
   (vla-ScaleEntity Obj (vla-get-Center Obj) 0.5))
 (princ))

 

Should work on Circles, Arcs, Ellipses, Elliptical Arcs...

Link to comment
Share on other sites

Or for a "batch" scale:

 

(defun c:scl (/ ss)
 (vl-load-com)
 (if (setq ss (ssget '((0 . "CIRCLE,ARC,ELLIPSE"))))
   (mapcar
     (function
       (lambda (Obj)
         (vla-ScaleEntity Obj
           (vla-get-Center Obj) 0.5)))
     (mapcar 'vlax-ename->vla-object
       (vl-remove-if 'listp
         (mapcar 'cadr (ssnamex ss))))))
 (princ))

Link to comment
Share on other sites

Further to my previous post "except Lee Mac"

 

Folk will forget how to operate AutoCad with all the Lee Mac lisp routines that appear :shock:

Link to comment
Share on other sites

I've moved this thread to the lisp section, although I have no idea why someone would need a lisp routine to scale an object? :?

Just use the SCALE command with your 'Center' Osnap activated.

Link to comment
Share on other sites

I've moved this thread to the lisp section, although I have no idea why someone would need a lisp routine to scale an object? :?

Just use the SCALE command with your 'Center' Osnap activated.

 

Neither could I, but I had fun writing it :)

Link to comment
Share on other sites

LeeMac, Eldon, Cad64:

Thank you so much guys..:D I appreciate your time:) Thanks to you LeeMac for the lisp, works perfectly and you even

included a batch scale-that's what I'm looking for!

 

where it all began::) I searched for this lisp because I have a project that contains many circlar symbols (as borehole

marks)..and my boss wanted them resized, quickly as usual hehe:) luckily, my symbols are in blocks.. so I got away with it easily.. However- I imagined, what if my circles are not blocked and i need them all resized quickly without loosing their critical location (centers)? it's indeed tiring to go one by one..so my search began, and eureka..and I found it here:shock: Thanks again!!!!

Link to comment
Share on other sites

  • 3 years later...

Hi lee,

 

I am happy to see your unconditional contribution on the net for cad users.

I also need some help from you. I need short lisp routine which can tell the scale the object has been enlarged or reduced, the scale at which the sketch has been drawn except the main drawing scale (ie dimscale)

 

ie i need a lisp routine by which if i use the distance command that would reply me with the scale that which the object is drawn. ie if the object is drawn at 1:5 and dimscale is 50. The object would have been scaled 5 times bigger.

 

so if the program could ask me the object dimension (prompt for input) and measure the distance (prompt) and calculate it. for example the object is 500mm wide square drawn 1:5 scale with dimscale of 1:50

 

then by 500(user input)/5000(scaled up distance- prompt for measuring)*(dimscale variable)50=5

 

the result could be able to reply (the object is drawn at scale 1:5)

 

and also to modify the sketch or draw the sketch at enlarged scale, the amount to be offsetted by multiplication based on relation to the dimscale;

 

ie, suppose the dimscale is 50 and i need to draw or modify object at 1:5 scale i need to multiply the lines by

 

500/5 *50 dimscale= 5000 the distance need to be offseted

 

 

 

so i need some kind of fix like factor that will remain untill i use this scale 1:5 for offset command after that the offset scale factor can be 1. variable for so that i dont have to multiple for every dimension

 

thanks in advance

 

Krishnao:)

 

Or for a "batch" scale:

 

(defun c:scl (/ ss)
 (vl-load-com)
 (if (setq ss (ssget '((0 . "CIRCLE,ARC,ELLIPSE"))))
   (mapcar
     (function
       (lambda (Obj)
         (vla-ScaleEntity Obj
           (vla-get-Center Obj) 0.5)))
     (mapcar 'vlax-ename->vla-object
       (vl-remove-if 'listp
         (mapcar 'cadr (ssnamex ss))))))
 (princ))

Link to comment
Share on other sites

Again I am flabbergasted why you should need a lisp written exclusively for you, when all model objects should be drawn at 1 to 1.

It confirms my suspicion that asking for a lisp, in some cases, is easier than knowing how AutoCAD works :shock:

Link to comment
Share on other sites

Again I am flabbergasted why you should need a lisp written exclusively for you, when all model objects should be drawn at 1 to 1.

It confirms my suspicion that asking for a lisp, in some cases, is easier than knowing how AutoCAD works :shock:

+1, draw all at 1:1 and create viewports with different scales. No need for any conversions anywhere.

 

Even the original OP's request could be performed without any coding: Just select all the circles (use filter or QSelect if you don't want to pick them one at a time) and change their radii through the Properties Palette. Only if each circle had a unique radius could I understand this scaleing routine. In any case for 2008+ I'd advise using annotative blocks instead.

Link to comment
Share on other sites

  • 2 years later...

Hi everyone,

 

Thank you for the lisp you wrote - it proved useful to me too. However i tried modifying it, because i have a lot of lines that i need to scale up individually and all by the same factor (for unavoidable reasons).

 

So how can i use the same lisp to scale a line, from it's midpoint with a factor of let's say 1.5?

Link to comment
Share on other sites

You could adjust the list to use the "centroid" of an object as the scaling base point. That should catch all possible object types. A "quick-fix" would be to get the bounding box, then average the XYZ's of the minimum and maximum points. Note though that's only a rough estimate of the "true" centroid (which is an ambiguous term in any case), but should suffice for stuff like lines. Polylines / regions / faces / solids would be a bit more complicated.

 

The issue with lines is, actually there is no "midpoint" (not like a circle / arc has a centre point). A line's mid point is calculated from its two endpoints.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...