Lisp for rotate Block with minus 90 deegree

Lisp for rotate Block with minus 90 deegree

Bin2009
Advocate Advocate
1,307 Views
21 Replies
Message 1 of 22

Lisp for rotate Block with minus 90 deegree

Bin2009
Advocate
Advocate

Hello, I work on same drawings need replace the old block with a new standard blocks, I use the function REPLACE BLOCK, but somehow, the new standard blocks all turned 90 degrees, I have to manually change the rotation angle, whatever the original-90 to get correct looking. For example, original rotation angle is 279, I need change to 189; if original rotation angle is 120, I need change to 30. There 5 different kinds of blocks, all have same problems, so I try to get a lisp can automatically change block rotation back 90 degrees.

Thank so much in advance!

Bin

0 Likes
Accepted solutions (1)
1,308 Views
21 Replies
Replies (21)
Message 2 of 22

cadffm
Consultant
Consultant

Hi,

 

 

>"somehow, the new standard blocks all turned 90 degrees"

Because the block content is drawn 90° rotated

 

If you have an old block with an error --> and the new block contains another arrow, rotated <==,

you have to rotate all blockreferences by 180° to match the old orientation.

 

 

Search for tools like "rotate bp" or rotate multiple objects

One sample search hit: Click!

 
 

 

 

Sebastian

0 Likes
Message 3 of 22

Bin2009
Advocate
Advocate

Thank for your suggestion, but I shouldn't modify the new standard block, because it is standard. If I manually change the old blocks rotation angle, also will take long time.  

0 Likes
Message 4 of 22

paullimapa
Mentor
Mentor

You should go to the source of the problem by talking to whoever created these new standard blocks.

Let them know that the original standard blocks were created using this angle.

Now the newly created standard blocks have changed in the original angle.

This problem needs to be fixed at the source and you should not have to deal with this conflict.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 22

Sea-Haven
Mentor
Mentor

Like @paullimapa it looks like the block definition is at 2 different angles depending on the dwg. Easiest way is use bedit and rotate the block and save block, all the blocks of that name will change direction.

0 Likes
Message 6 of 22

cadffm
Consultant
Consultant

Think about, the source issue can be on both sides.

 

If you have one standard block for a CAR and you have to replace all cars in all files, now and then, also in files from others/outside,

it is not the right way to edit the (new) standard CAR block 😄

 

But if someone created this new block for this drawing only, then it is. But I wouldn't call it "new standard block" 🤔

 

Sebastian

0 Likes
Message 7 of 22

Kent1Cooper
Consultant
Consultant

A starting point could be SpinText.lsp [attached], which rotates Text objects about each one's insertion point, by whatever amount of rotation you specify.  It's for Text, but changing that to Blocks would be a simple matter.

But talk about selection options.  I assume you would not want the Blocks equivalent of the all-Text-in-the-entire-drawing selection it offers.  But it could be made, for example, to ask you to select one Block and it could find all others of the same name, rather than requiring you to pick them all yourself [but maybe the latter is what you want].

And questions arise:  Does this ever involve dynamic Blocks?  [That would make it more complicated for it to find all those of the same name as one you select.]  Would there be some with differences in positive-negative on the X & Y scale factors?  [That could rotate some effectively in the wrong direction if the rotation isn't 180°.]

Kent Cooper, AIA
0 Likes
Message 8 of 22

ronjonp
Mentor
Mentor

@Bin2009 Maybe this?

 

 

(defun c:br90 (/ s o)
  (if (setq s (ssget ":L" '((0 . "INSERT"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (vla-put-rotation (setq o (vlax-ename->vla-object e)) (- (vla-get-rotation o) (/ pi 2.)))
    )
  )
  (princ)
)

 

 

 

0 Likes
Message 9 of 22

Kent1Cooper
Consultant
Consultant

@ronjonp wrote:
(vla-put-rotation (vlax-ename->vla-object o) (- (vla-get-rotation o) (/ pi 2.)))

Should that line be more like this?

(vla-put-rotation (setq o (vlax-ename->vla-object e) (- (vla-get-rotation o) (/ pi 2.)))

[untested]

Kent Cooper, AIA
0 Likes
Message 10 of 22

ronjonp
Mentor
Mentor

@Kent1Cooper Oops .. updated above.

0 Likes
Message 11 of 22

komondormrex
Mentor
Mentor

@ronjonp 

pi is real number, what for is (/ pi 2.

0 Likes
Message 12 of 22

ronjonp
Mentor
Mentor

See if this sheds any light 🙂

(angtof "90")
;; 1.5708 
(/ pi 2)
;; 1.5708 
0 Likes
Message 13 of 22

pkenewell6347
Advocate
Advocate
Accepted solution
0 Likes
Message 14 of 22

Sea-Haven
Mentor
Mentor

Been discussed many times about divide in particular returning a real v's an integer and like @ronjonp I try to use a decimal in my numbers often just the decimal point rather than x.0, (/ 3 2) = 1 ?? (/ 3 2.) = 1.5 (/ 3. 2) = 1.5 I guess just a good habit to get used to.

0 Likes
Message 15 of 22

Bin2009
Advocate
Advocate

Hello Kent, 

Your lisp is work perfectly for the text!
My block is dynamic block without any text.

Thank you very much!

Bin

0 Likes
Message 16 of 22

Bin2009
Advocate
Advocate

Hello Ronjonp.

Thank you so much for your lisp, somehow is not working properly, show some error when loading, I try to figure out why.

Best regards,

Bin

0 Likes
Message 17 of 22

Bin2009
Advocate
Advocate

Hello Pkenewell,

Thank you so much, the resource you give me provided the lisp can rotate all the objects based on their own reference points, This is perfect for me. because all my blocks which need to be rotated, all setting on one layer, also that layer only have the blocks object, so I can isolate the layer, then use the lisp rotate all the blocks.

Highly appreciate!

Bin

Message 18 of 22

braudpat
Mentor
Mentor

Hello @Bin2009 

 

I am using often these 2 Lisp routines : 

 

BROT : "Relative" Rotation of Blocks 

 

BSCA : "Relative" Scale of Blocks

 

AND I have exactly the same routines for TEXT / MTEXT :  TROT  &  TSCA ...

 

Maybe these routines could help you !?

 

Bye, Pat

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 19 of 22

komondormrex
Mentor
Mentor

actually i have meant decimal point) do not understand what direction you are lightening.

komondormrex_0-1739888331150.png

0 Likes
Message 20 of 22

ronjonp
Mentor
Mentor

@Bin2009 wrote:

Hello Ronjonp.

Thank you so much for your lisp, somehow is not working properly, show some error when loading, I try to figure out why.

Best regards,

Bin


Weird .. works fine here:

2025-02-18_08-22-19.gif

0 Likes