Jump to content
justindm

Rotate multiple blocks around their individual origin point

Recommended Posts

justindm

Does anyone have or know of any lisp routines that will allow me to rotate all selected blocks 180 degrees (or any user defined direction) around their individual center/origin points?

 

The blocks I have are directional (signs, street lights, etc...) so each has to face a different direction. Right now they are all facing the opposite direction they need to be...

Match properties, etc...won't work for this.

Share this post


Link to post
Share on other sites
Lee Mac
(defun c:test ( / ss ang ) (vl-load-com)

 (if (and (setq ss  (ssget "_:L" '((0 . "INSERT"))))
          (setq ang (getangle "\nSpecify Rotation Angle: "))
     )
   (
     (lambda ( i / e o )
       (while (setq e (ssname ss (setq i (1+ i))))
         (vla-put-rotation (setq o (vlax-ename->vla-object e))
           (+ (vla-get-rotation o) ang)
         )
       )
     )
     -1
   )
 )

 (princ)
)

Share this post


Link to post
Share on other sites
justindm

Exactly!!!!! Thanks Lee!! :thumbsup:

Share this post


Link to post
Share on other sites
Lee Mac

You're welcome :)

Share this post


Link to post
Share on other sites
justindm

would there be a way to add something allowing me to select the blocks by name? some of my layers have multiple blocks. some need to be rotated and some don't...

Share this post


Link to post
Share on other sites
Lee Mac

Add

 

(2 . "YourBlockNameHere")

 

Next to (0 . "INSERT")

Share this post


Link to post
Share on other sites
pBe

Lee Mac,

I notice you use

(setq ang (getangle "\nSpecify Rotation Angle: "))

 

Which can also be use to select 2 points on the screen. it works well with Numerical input, only thing is if by chance the user wants to pick two points on the screen for the angle current ucs may be a factor as for the end result. is there a way around this?

Share this post


Link to post
Share on other sites
Lee Mac
Lee Mac,

I notice you use

(setq ang (getangle "\nSpecify Rotation Angle: "))

 

Which can also be use to select 2 points on the screen. it works well with Numerical input, only thing is if by chance the user wants to pick two points on the screen for the angle current ucs may be a factor as for the end result. is there a way around this?

 

A good point, I suppose you could use:

 

(defun c:test ( / ss ang ) (vl-load-com)

 (if (and (setq ss  (ssget "_:L" '((0 . "INSERT"))))
          (setq ang (getangle "\nSpecify Rotation Angle: "))
          (setq ang (+ ang (angle '(0. 0. 0.) (trans (getvar 'UCSXDIR) 0 (trans '(0. 0. 1.) 1 0 t) t))))
     )
   (
     (lambda ( i / e o )
       (while (setq e (ssname ss (setq i (1+ i))))
         (vla-put-rotation (setq o (vlax-ename->vla-object e))
           (+ (vla-get-rotation o) ang)
         )
       )
     )
     -1
   )
 )

 (princ)
)

 

This will disregard the UCS and just use the two points in WCS.

Share this post


Link to post
Share on other sites
pBe
A good point, I suppose you could use:

 


(setq ang (+ ang (angle '(0. 0. 0.) (trans (getvar 'UCSXDIR) 0 (trans '(0. 0. 1.) 1 0 t) t))))

 

I was thinking along the same line. but yours is much better.

we're having a grand time picking your brain Lee Mac... a wondeful way to learn :)

Thank you very much :thumbsup:

Share this post


Link to post
Share on other sites
Lee Mac

You're welcome pBe :)

Share this post


Link to post
Share on other sites
stevesfr

Lee, when using the program to rotate block(s) having attributes, the attributes are rotated about their insertion points as well as the block about its insertion point. It would be nice to have the option to rotate the block and the attributes wholly about the block insertion point (similar to Rotate command, however using Rotate command and windowing more than one block only allows the selection of one base point or one INS point.)

Just a thought...

Steve

Share this post


Link to post
Share on other sites
Lee Mac
It would be nice to have the option to rotate the block and the attributes wholly about the block insertion point

 

This should be the current behaviour as I am only changing the Block rotation, and this is the behaviour I am seeing upon testing. Does anyone else see the behaviour Steve describes?

Share this post


Link to post
Share on other sites
stevesfr
This should be the current behaviour as I am only changing the Block rotation, and this is the behaviour I am seeing upon testing. Does anyone else see the behaviour Steve describes?

 

attached is my dwg with the block acting funky

Steve

test-br.dwg

Share this post


Link to post
Share on other sites
pBe

The only time i see blocks with attributes behave that way is when you use Annotative text style with match text orientation to layout mode,

but the sample you attached clearly is not. :?

 

I've tried attaching a file, but somehow the attachment button is not responding

Share this post


Link to post
Share on other sites
irneb

I'm sorry to say, but that's how a block with attributes works - even Locking the attribs in place inside the block def doesn't help. If you change the block's rotation using the properties palette (which is basically doing the same as Lee's code) then the attributes don't rotate around the block's insertion - they may change direction, but they all have their own insertion points about which they adjust. To fix it after the fact, you could use AttSync / BAttMan - but be warned it screws-up mirrored blocks.

 

Otherwise you need to modify Lee's routine to actually do a rotate command on each block in turn - instead of just changing its rotation property. This would rotate the block together with its attribs - as you would expect. Though that's going to make the routine extremely slow.

Share this post


Link to post
Share on other sites
Movieangel

I know this is a super old topic but I am trying to do the same thing with scale. I have used your rotate lsp several times and know that it is probably super easy to do the same thing to have all the blocks scale from their orgin point but unfortunatly I don't know enough about .lsps to modify it to do that. I am going to give it a shot but I thought I would just throw it out there in case it is actually a 2 minute fix and will take me 2 hours. Thanks so much for the rotate lsp. It saved me a ton of time today.

Share this post


Link to post
Share on other sites
Lee Mac

Firstly, glad you could make use of the rotation program.

 

You could change the scale of multiple blocks without LISP just by selecting your blocks (QSelect perhaps), going to the Properties panel and changing the X,Y,Z Scale values.

 

But the LISP is just as simple for the task:

 

(defun c:BlockScale ( / c e i s x )
   (if
       (and
           (setq s (ssget "_:L" '((0 . "INSERT"))))
           (setq x (getdist "\nSpecify New Scale for Blocks: "))
       )
       (repeat (setq i (sslength s))
           (setq e (entget (ssname s (setq i (1- i)))))
           (foreach c '(41 42 43)
               (setq e (subst (cons c x) (assoc c e) e))
           )
           (entmod e)
       )
   )
   (princ)
)

Share this post


Link to post
Share on other sites
Movieangel

You seriously amaze me Lee Mac. I wish my brain thought in code as easily as yours does. This is the third problem you have helped me with. I use the Stud.lsp very frequently too. Thanks so much. The scale lsp actually didn't work for the text in my attributes but you are right in that I can just use the properties. I use properties for everything else, I don't know why I didn't think to use it for this. Thanks again.

Share this post


Link to post
Share on other sites
Lee Mac

Thanks Movieangel, you flatter me :)

Share this post


Link to post
Share on other sites
mpozauko

hey guys. i wonder if it's possible to make all selected blocks perpedicular on a 3d/2d pline? i was looking for a lisp to do this all over different forums but no success.

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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