Code Red > AutoLISP (Vanilla / Visual)

Scaling a list of blocks from a know point

<< < (2/2)

BIGAL:
A command line variation so that you do not have to hard code the block names. Note the block names must be typed case correct.

(c:scaleblocks (list  "Block1" "Block2" "Block3"))


--- Code: ---(defun c:scaleblocks (lst / bpt fac idx obj sel )
    (setq
        bpt '(0.0 0.0 0.0) ;; Base point
        fac 1.06382978723  ;; Scale factor
       
    )
    (if (setq sel (ssget "_X" (append '((0 . "INSERT") (-4 . "<OR") (2 . "`*U*")) (mapcar '(lambda ( n ) (cons 2 n)) lst) '((-4 . "OR>")))))
        (repeat (setq idx (sslength sel))
            (if (and (member (strcase (vla-get-effectivename (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))))) lst)
                     (vlax-write-enabled-p obj)
                )
                (vlax-invoke obj 'scaleentity bpt fac)
            )
        )
    )
    (princ)
)
(vl-load-com) (princ)

--- End code ---

ronjonp:

--- Quote from: BIGAL on April 26, 2017, 11:14:57 PM ---A command line variation so that you do not have to hard code the block names. Note the block names must be typed case correct.

(c:scaleblocks (list  "Block1" "Block2" "Block3"))


--- Code: ---(defun c:scaleblocks (lst / bpt fac idx obj sel )
    (setq
        bpt '(0.0 0.0 0.0) ;; Base point
        fac 1.06382978723  ;; Scale factor
       
    )
    (if (setq sel (ssget "_X" (append '((0 . "INSERT") (-4 . "<OR") (2 . "`*U*")) (mapcar '(lambda ( n ) (cons 2 n)) lst) '((-4 . "OR>")))))
        (repeat (setq idx (sslength sel))
            (if (and (member (strcase (vla-get-effectivename (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))))) lst)
                     (vlax-write-enabled-p obj)
                )
                (vlax-invoke obj 'scaleentity bpt fac)
            )
        )
    )
    (princ)
)
(vl-load-com) (princ)

--- End code ---

--- End quote ---
Don't forget this part: (mapcar 'strcase lst) .. otherwise the member check is case sensitive.

Navigation

[0] Message Index

[*] Previous page

Go to full version