Select all Blocks rotated 180 degrees, Isolate them, then rotate all by 180 degrees at their insertion point

Select all Blocks rotated 180 degrees, Isolate them, then rotate all by 180 degrees at their insertion point

johnlagasse
Contributor Contributor
1,070 Views
9 Replies
Message 1 of 10

Select all Blocks rotated 180 degrees, Isolate them, then rotate all by 180 degrees at their insertion point

johnlagasse
Contributor
Contributor

I have a client that created racks and inserted them at 0 and 180 degrees. I'm trying to rotate the 180 degree racks back to 0. I have another app that is replacing the racks and when they are at 180 they don't land where they are supposed to.  Thanks!

0 Likes
Accepted solutions (2)
1,071 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant
(defun c:RotateB180 ( / s i)
  (if (setq s (ssget (list '(0 . "INSERT") (cons 50 pi))))
    (repeat (setq i (sslength s))
      (setpropertyvalue (ssname s (setq i (1- i))) "Rotation" 0.)))
  (princ)
  )
0 Likes
Message 3 of 10

johnlagasse
Contributor
Contributor

I have a thousand or so blocks where some are inserted at 0 and some are 180. I want to select all the blocks but only have the blocks that are rotated 180 degrees to be in the selection set. Then I want to isolate them so I know which are at 180, then rotate them by 180 degrees.

0 Likes
Message 4 of 10

ВeekeeCZ
Consultant
Consultant

Are you sure you are in the right place?

0 Likes
Message 5 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

The code I've posted selects all blocks with the "Rotation" property of 180°(pi radians in fact) and sets the rotation to 0. 

0 Likes
Message 6 of 10

johnlagasse
Contributor
Contributor

Wouldn't this be where I'd ask for LISP help.  The rotate 180 LISP you created works great. Just wondering how to select blocks based on their rotation angle. I'm just getting back into the LISP world and not sure how to write a LISP that will do that. I'm very rusty. 🙂

 

0 Likes
Message 7 of 10

johnlagasse
Contributor
Contributor

Sorry I was using it wrong.  Works great!  Thanks

 

0 Likes
Message 8 of 10

calderg1000
Mentor
Mentor
Accepted solution

Regards @johnlagasse 

Try this code

 

;;;Rotate blocks to 0 degree angle
(defun c:rtb (/ s i)
  (setq s (ssget (list '(0 . "insert") (cons 50 pi))))
  (repeat (setq i (sslength s))
    (setq sn (entget (ssname s (setq i (1- i)))))
    (entmod (subst (cons 50 0) (assoc 50 sn) sn))
  )
)

;;;It only selects blocks rotated 180 degrees.
(defun c:stb (/ s i)
  (setq s (ssget (list '(0 . "insert") (cons 50 pi))))
  (sssetfirst nil s)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 9 of 10

johnlagasse
Contributor
Contributor

That works perfectly.  I can isolate the racks rotate 180 and manipulate only them. Since rotating them places them in a different position I can select similar and move each type of rack back into position.  THANKS!

0 Likes
Message 10 of 10

calderg1000
Mentor
Mentor
Glad to help, cheers

Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes