change block scale

Why does this only change the scale of 1 block in the selection set?

(setq ss (ssget "_X" '((0 . "INSERT") (2 . "BIOA1_v*,LNO_BHPB_A1,NW_BHPB*"))))
(setq sc (getreal "\nSpecify scale [1/2/5/10/15/20/25]:"))
(if ss
(progn
(setq blk (vlax-ename->vla-object (ssname ss 0)))
(vlax-put-property blk 'XEffectiveScaleFactor sc)
(vlax-put-property blk 'YEffectiveScaleFactor sc)
(vlax-put-property blk 'ZEffectiveScaleFactor sc)
)
)

Comments

  • (ssname ss 0) returns the first block in the selection set. You'd have to repeat that line and the three Put lines for (ssname ss 1) in order to set the scale of the second block in the set, and for (ssname ss 2) to set the scale of the third block, etc.

    Since you don't know how many blocks are in the selection set, you should use a variable instead of the 0, 1, 2, etc., and use the (while) or (foreach) function to step through the selection set and set the scale for each block. Use (sslength) to get the number of blocks in the set and set up a counting variable to step through the selection set that many times.
  • Thanks Anthony, I will look into this

    (ssname ss 0) returns the first block in the selection set. You'd have to repeat that line and the three Put lines for (ssname ss 1) in order to set the scale of the second block in the set, and for (ssname ss 2) to set the scale of the third block, etc.

    Since you don't know how many blocks are in the selection set, you should use a variable instead of the 0, 1, 2, etc., and use the (while) or (foreach) function to step through the selection set and set the scale for each block. Use (sslength) to get the number of blocks in the set and set up a counting variable to step through the selection set that many times.

  • Anthony Apostolaros
    edited January 26
    If you want to assign a different scale to each block, the numeric data input has to be part of the loop too. It should come after getting the name of the next block, but before assigning any scale factors to it. I assume you want that, because if you wanted them all the same scale the user could do that for the whole selection set at once via the Properties panel.
  • My $0.05

    (setq ss (ssget "_X" '((0 . "INSERT") (2 . "BIOA1_v*,LNO_BHPB_A1,NW_BHPB*"))))
    (setq sc (getreal "\nSpecify scale [1/2/5/10/15/20/25]:"))
    (if ss
    (repeat (setq x (sslength ss))
    (setq blk (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
    (vlax-put-property blk 'XEffectiveScaleFactor sc)
    (vlax-put-property blk 'YEffectiveScaleFactor sc)
    (vlax-put-property blk 'ZEffectiveScaleFactor sc)
    )
    )
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!