Block scaling routine

Block scaling routine

andreas7ZYXQ
Advocate Advocate
997 Views
3 Replies
Message 1 of 4

Block scaling routine

andreas7ZYXQ
Advocate
Advocate

Hi.
Im kind of stuck how to build my code since im a beginner. And i was looking for someone that could help me? 😃 😛

Im looking for a routine that will scale my blocks. and keep them att the point that they are inserted in.
I want to be able to scale multiple blocks by selecting them.

save the point for example this, and not move them.

(10 -55100.0 -28500.0 0.0)


I want to filter so i cant choose anything else.

 

(0 . "INSERT")

 
Modify dxf codes

(41 . 50.0)
(42 . 50.0)
(43 . 50.0)

Its also omportant that all my content in my block also scales, i found a routine that will scale but my attribute inside is still att scale  1 instead of my new value 50.

how can i include a getkword function with my (50 100 150 200 250 300 350 400) scale options?



I used this one from Lee Mac but it wont fulfil my needs to 100%.

(defun c:scl ( / enx idx scl sel )
    (initget 6)
    (if (and (setq scl (getdist "\nSpecify scale factor: "))
             (setq sel (ssget "_:L" '((0 . "INSERT"))))
        )
        (repeat (setq idx (sslength sel))
            (setq enx (entget (ssname sel (setq idx (1- idx)))))
            (foreach dxf '(41 42 43)
                (setq enx (subst (cons dxf scl) (assoc dxf enx) enx))
            )
            (entmod enx)
        )
    )
    (princ)
)
0 Likes
Accepted solutions (1)
998 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@andreas7ZYXQ wrote:

....
I used this one from Lee Mac but it wont fulfil my needs to 100%. ....


First question:  In what way does that routine fall short?  It looks like it should do exactly what you're asking.

 

If it's not scaling Attributes, then the next question is:  Are your Blocks always INSERTed at equal X & Y scale factors?  If so, a routine would be pretty easy to write, using the SCALE command and the Reference option.  Modifying Lee's [untested]:

 

(defun c:scl (/ ent enx idx scl sel)
    (initget 6)
    (if (and (setq scl (getdist "\nSpecify scale factor: "))
             (setq sel (ssget "_:L" '((0 . "INSERT"))))
        )
        (repeat (setq idx (sslength sel))
            (setq

              ent (ssname sel (setq idx (1- idx)))

              enx (entget ent)

            )
            (command "_.scale" ent ""

              (cdr (assoc 10 enx)); insertion point

              "_reference" (cdr (assoc 41 enx)) scl

            )
        )
    )
    (princ)
)

Kent Cooper, AIA
0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
First question:  In what way does that routine fall short?  It looks like it should do exactly what you're asking.
If it's not scaling Attributes, ....

[I just tried Lee's on some Blocks with Attributes, and it does, in fact, scale the Blocks' non-Attribute contents, but not their Attributes.  So I tested mine (what a concept!), and the Attributes are  scaled along with the Blocks.]

Kent Cooper, AIA
0 Likes
Message 4 of 4

andreas7ZYXQ
Advocate
Advocate

Thanks alot @Kent1Cooper it works just as i wish.

Just saved another day here, flawless!

0 Likes