marmo Posted March 24, 2011 Posted March 24, 2011 Hello everyone, you know of a lisp that implements the command "undo" with selection set of objects? For example: 1 - I have a set of objects throughout the design (50 for example, lines, blocks etc.). 2 - I select these objects and move them with the command "move". 3 - after this I draw, copy and move other objects (lines, blocks, text, etc.). 4 - I realize that the operation in step 2 was wrong: instead of moving the objects I had to copy them. If I use the undo command to the point 2 are not able to retrieve the selection of 50 items. Is there a lisp "undo special" that also considers the selections? Obviously if 50 items are selected one by one, the only selection "interesting" is that just before the command "move" in section 2 or generally just before any command. Thanks. Regards, Marco Quote
pBe Posted March 24, 2011 Posted March 24, 2011 (edited) here's a short and simple way to accomplish that. (defun c:nmove () (setq pre_sel (ssget) p1 (getpoint) p2 (getpoint p1)) (command "_.move" pre_sel "" p1 p2) ) and (defun c:unmove () (command "_copy" pre_sel "" p2 p1)) use nmove like you ordinarily use the move command ...after this I draw, copy and move other objects (lines, blocks, text, etc.) I realize that the operation in step 2 was wrong: instead of moving the objects I had to copy them..... command: unmove This will copy the previous objects to the original location Try it and tell me what you think Ooops. just realize something, if you make any modification on the selected objects then a copy would be useless, otherwise we need to write a more complex program invoking vla-CopyObjects oh well... Or it can as simple as (defun c:nmove nil (command "_.copybase" '(0.0 0.0) (ssget) "" ) (command "_.move" "p" "") ) (defun c:unmove nil (command "_pasteblock" '(0.0 0.0) "_explode" "Last" "") ) Edited March 24, 2011 by pBe light bulb Quote
pBe Posted March 24, 2011 Posted March 24, 2011 but then again, its only as good as the last call to nmove. what we can do is create named blocks for every call to nmove and eradicate the blocks after the drawing session. would you really want to do that? I think its doable Quote
Lee Mac Posted March 24, 2011 Posted March 24, 2011 Are you saying that you want to be able to automatically select those same objects again following the undo procedure? Quote
JohnM Posted March 24, 2011 Posted March 24, 2011 I think I understand what you are asking but I could be wrong. AutoCAD only remembers the last selection set. Every time you select an object or a group of objects a selection set is made. When you use the undo command the selection set is cleared from memory. You could write a lisp program using a reactor to store a list of selection sets and have a dialog box display them, then you could go back through them and have the program reselect them, then you could do what ever you need to do from that point on. The problem is that every time you select anything it will be added to the list and after working for a while the list could get extremely long. Also you would have to have some good error checking in case you deleted an object that was part of a previous selection set. Quote
alanjt Posted March 24, 2011 Posted March 24, 2011 Yeah, this has bad idea written all over it. Quote
marmo Posted March 24, 2011 Author Posted March 24, 2011 Hello everyone, thanks for the replies. I think JohnM said better what I meant. I imagine an undo command that remembers and highlights the selection of objects related to the action/command that is undone. Think will work or is it complicated? Thanks. Quote
JohnM Posted March 24, 2011 Posted March 24, 2011 The program is possible but you need to figure out in great detail what you want it to do. I will not spend time writing it but I will be happy to help out once you start and post some questions when you get stuck or need advice. And I’m sure others will help out as well. Quote
ILoveMadoka Posted April 13, 2011 Posted April 13, 2011 If I know I need to manipulate 2 different selection sets and go back and forth between them (or in this case an UNDO) I just predefine the selections sets. Personally, I just enter it from the command line: (setq SS1 (ssget)) Then select your objects. Then for the second selection set (setq SS2 (ssget)) Select your second set. Entering !SS1 (or !SS2) at a Select Objects: prompt will select those objects again. You just have to know in advance that you're going to need the Selection Set again. If there is a preferred method for doing this please advise.. I do this a lot!! Thanks! Quote
SOliver Posted April 14, 2011 Posted April 14, 2011 Rather than move the first set of objects would it be possible to select the base point and destination point, carry out the draw methods and then move them at the end or better yet offset the coordinates used in the draw methods by the distance between the base and destination points? Quote
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.