justindm Posted December 2, 2010 Share Posted December 2, 2010 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2010 Share Posted December 2, 2010 (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) ) Quote Link to comment Share on other sites More sharing options...
justindm Posted December 2, 2010 Author Share Posted December 2, 2010 Exactly!!!!! Thanks Lee!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2010 Share Posted December 2, 2010 You're welcome Quote Link to comment Share on other sites More sharing options...
justindm Posted December 2, 2010 Author Share Posted December 2, 2010 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... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 2, 2010 Share Posted December 2, 2010 Add (2 . "YourBlockNameHere") Next to (0 . "INSERT") Quote Link to comment Share on other sites More sharing options...
pBe Posted December 3, 2010 Share Posted December 3, 2010 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 3, 2010 Share Posted December 3, 2010 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. Quote Link to comment Share on other sites More sharing options...
pBe Posted December 4, 2010 Share Posted December 4, 2010 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 4, 2010 Share Posted December 4, 2010 You're welcome pBe Quote Link to comment Share on other sites More sharing options...
stevesfr Posted December 4, 2010 Share Posted December 4, 2010 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 4, 2010 Share Posted December 4, 2010 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? Quote Link to comment Share on other sites More sharing options...
stevesfr Posted December 4, 2010 Share Posted December 4, 2010 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted December 5, 2010 Share Posted December 5, 2010 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 Quote Link to comment Share on other sites More sharing options...
irneb Posted December 6, 2010 Share Posted December 6, 2010 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. Quote Link to comment Share on other sites More sharing options...
Movieangel Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 12, 2012 Share Posted January 12, 2012 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) ) Quote Link to comment Share on other sites More sharing options...
Movieangel Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 12, 2012 Share Posted January 12, 2012 Thanks Movieangel, you flatter me Quote Link to comment Share on other sites More sharing options...
mpozauko Posted January 12, 2012 Share Posted January 12, 2012 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.