Jump to content

Help - Scale about Center by a Specific Value


Recommended Posts

Posted (edited)

Hi all,
Is it possible to modify this Lee Mac code, to always Scale up by 2 (instead of having the user to enter a value)? Thank you.

 

https://www.cadtutor.net/forum/topic/38409-looking-for-a-lisp-which-scale-objects-with-its-own-center-point/

 

;; Scale About Center - Lee Mac

(defun c:sac ( / ll sel obj ur )
   (initget 6)
   (if
       (and
           (setq *scl*
               (cond
                   (   (getdist (strcat "\nSpecify Scale Factor" (if *scl* (strcat " <" (rtos *scl* 2) ">: ") ": "))))
                   (   *scl*   )
               )
           )
           (ssget "_:L")
       )
       (progn
           (vlax-for obj (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
               (if (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'll 'ur))))
                   (vla-scaleentity obj
                       (vlax-3D-point
                           (mapcar '(lambda ( a b ) (/ (+ a b) 2.0))
                               (vlax-safearray->list ll)
                               (vlax-safearray->list ur)
                           )
                       )
                       *scl*
                   )
               )
           )
           (vla-delete sel)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Edited by barristann
Posted

Try this mod:
 

;; Scale About Center - Lee Mac

(defun c:sac ( / ll sel obj scl ur )
   (if
       (and
           (setq scl
               2
           )
           (ssget "_:L")
       )
       (progn
           (vlax-for obj (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
               (if (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'll 'ur))))
                   (vla-scaleentity obj
                       (vlax-3D-point
                           (mapcar '(lambda ( a b ) (/ (+ a b) 2.0))
                               (vlax-safearray->list ll)
                               (vlax-safearray->list ur)
                           )
                       )
                       scl
                   )
               )
           )
           (vla-delete sel)
       )
   )
   (princ)
)
(vl-load-com) (princ)

 

  • Like 1
Posted

You are amazing ronjonp! It works wonders! Thank you ronjonp.

Posted
12 hours ago, barristann said:

You are amazing ronjonp! It works wonders! Thank you ronjonp.

Glad to help. 🍻

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...