Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW DO YOU SELECT THE LAST ITEMS COPIED ??

Status
Not open for further replies.

shadow

Computer
Mar 1, 2001
321
0
0
US
Trying to in a Button macro select objects then copy then lake the copies and place them on the current layer but when i call the l for the last objects then it only selects the last 1 so if there were 2 or more copied then only one gets selected does anyone know what you do to select the last created set of items or am i going about this the wrong way im not looking for all in a lsp im just trying to do something short and simple if everyone helps everybody the world will be a better place
 
Replies continue below

Recommended for you

You can use "previous" to get the entire selection set. I did something like this to make a function that rotates a copy of a selection set. The trick is that previous is going to return the original selection set, rather than the copied objects. But, you are never stuck with AutoCad, procedurally, this is how you can do what you are after:

1)Get the selection set
2)Copy "previous" from 0,0 to 0,0 (now the copied objects are right "on top of" the selection set)
3)Move "previous" (you will actually be moving the original selection set "out from under" the copies)
4)Change the layer of the "previous" selection set to the current layer.

To fancy this up, you will want to "erase" "previous" if the function is cancelled by the user.
 
i know all that but try this
command
select
select some objects
then start the copy command
when it asks you to select objects use p for previous
then after you place the copy somewhere the do a select l for last it only selects 1 object wuts up with that this is in acad 2002 if everyone helps everybody the world will be a better place
 
Shadow,
Try this routine, it uses idea from engrmech_vis about copying in place, then your selection set is becomes your new items.
Regards,
Carl

(defun c:ccl ()
(princ "Copy to current layer")
(setq ss1 (ssget))
(setvar "cmdecho" 0)
(command "._copy" ss1 "" "0,0" "0,0")
(setq pt1 (getpoint "\from point: "))
(command "._change" ss1 "" "_p" "_la" (getvar "clayer") "")
(command ".move" ss1 "" pt1)
(princ "to point: ")
(command pause)
(setvar "cmdecho" 1)
(princ)
);defun
(princ "\nStart with CCL")
(princ)
 
Shadow, you didn't read my post carefully, CarlB got the idea. Here's the rotate retaining old objects code that I mentioned earlier:

Code:
(defun rcopyerror(s)
(command "erase" "p" "")
(princ)
(princ (strcat "\nError: " s))
(setq *error* olderr)
);end rcopyerror



(defun C:RCOPY()
(setvar "CMDECHO" 0)
   (princ "Rotate Retaining Old Objects")
   (ssget)
   (command "copy" "p" "" "0,0" "0,0")

(setq olderr *error*
      *error* rcopyerror);redefine error handler

   (setvar "CMDECHO" 1)
   (command "rotate" "p" "" pause "r" "@" pause pause)
   (setvar "CMDECHO" 0)
   (command "redraw")
   (menucmd "s=chla")
   (prompt "Select new Layer for RCOPIED Objects, or RETURN for No Change")
   (command "change" "p" "" "properties" "la" pause "")
   (menucmd "s=rotate")
   (princ)
   (setq *error* olderr);reset the error handler
);end rcopy

This has the error handling in place to delete the copy if you cancel, and you should be able to adapt it by combining with Carl's code. The menucmd "s=chla" calls up a menu (sidebar) that lets the user pick from the menu to decide which layer to put things on, you could adapt it by just getting the current layer.
 
^C^Cselect;\_Copy;P;;\\_change;L;;p;la;(getvar "clayer");;

this is the button macro that im using give it a shot the key is the copy isnt in the same spot as the original if everyone helps everybody the world will be a better place
 
Carl and I are telling you what to do...

You just aren't hearing.

I confess that I don't know beans about button macros, if I had to guess, you won't get what you want without writing a lisp routine. I learned Acad long ago, and have nver done anything with button macros. The last I used Acad was r14, (Inventor user now) and I used pull-down and side (screen) menus, feeling that pallets and buttons were just screen (area) wasting, marketing stuff.

Lisp is not pretty to look at, but after using it some you can make sense of it. The routines (lisp) that Carl and I have provided get you close to what you want. I'll lead you thru what I'm talking about: I assume classic Acad selection setting (verb/noun) which is to say; I first specify that I want to do, Copy/Erase/Move/Whatever, then select the object(s) that I want to do that to, hit ENTER, then specify, From "Here" to "There". If you don't understand what I mean, you need to quit posting to this forum and go learn Acad (just being honest, trying to help).

Type what I put in quotes to the command line; This is a good way to concept and start (even debug) anything that you plan to do with lisp.

1)Get the command line up (does Acad still have that?).
2)Draw 3 lines.
3)Type: "copy" ENTER
4)Select the 3 lines in whatever way pleases you, "Enter" to complete the selection set.
5)Acad is asking: From: type "0,0" hit "Enter"
6)Acad is asking: To: type : "0,0" hit "Enter"
7)Type: "Move" ENTER
8)Type: "p" (meaning PREVIOUS) hit "Enter"
9)Acad is asking: From: Pick a Point
10)Acad is asking: To: Pick a (different) point
11)You have now moved the original 3 lines "out from under" the copies, and completed the task that you said you wanted, except for the layer change, which can be done using the steps in the "Rcopy" routine that I posted, with some modifications...

You could paste the rcopy code into a file, save it as rcopy.lsp (using wordpad), then load it at the command line by typing: "load rcopy.lsp", then type "rcopy" and follow the prompts... To do this, the lisp file needs to be in Acad's search path, or you need to specify the path completely when you load it. Loosing strength, cannnt' keeeppppp finggggersssssssss muvinngggg. gud nite



 
Shadow,
It looks like your bit of macro button code might work if you just use "P" (Previous) instead of "L" (Last) when you want to change layers. Last is just that: the last entity that was created, where previous is the previous selection set.
The idea of doing this with lisp seems good, since it allows you to delete the copies if the user cancels...
 
Thats what im saying l should work but it doesnt and p moves the original not the copy so if the copy does not exist on top of the original you have just moved your originals to a new location but why would you want to do this wouldnt you think that l should mean the last obbjects selected and shouldnt matter how many you had selected in the first place i understand what everyone is talking about they are saying make a copy and place it on top of the original then move it to the desired location but moving "it" is the question what it are we talking about the original objects or the copy try it do the copy command make a copy of an object and place the insertion point some where other than 0,0 then try selecting p or l and see where you get im not saying you all are wrong im just saying who would do something like this this way what is the point of moving the original objects cause what if its a block with attribs that after you copy it you didnt want the block to be populated with the same stuff what if you have a lsp that looks at the attrib info an acts on that so again

How do you copy and place the copy somewhere else othere than on top of the original and still be able to select it with p or l if everyone helps everybody the world will be a better place
 
shadow,

Do you even know how to utilize AutoLISP? If you were to take the power of the AutoLISP that was posted in this thread, all you'd need to do if put the call to the LISP routine in your button. Button still works and you have the greater ability of a LISP routine.
 
Yes but the point is that Autodesk in the infinate wisdome :0 forgot to make it so that selecting last ment the last selected item(s) not item yes i do understand all of this and im thinking hard about how 2 best utilise it all in a way that would be easies for anyone to use if everyone helps everybody the world will be a better place
 
Last means last!
Previous means the previous selection set.

It should not matter to you or your users whether the copies (which are exact copies) or the original selection set is what gets moved. You can do this from the command prompt as engrmech posted above and see that you get the results desired. If you understand how to do lisp, the work is already 90% done for you, just paste the code that has been posted and modify it. This shouldn't take any "hard thinking"...
 
Shadow,
You are thinking too hard.

To address your point about "what if the original block had attributes and you didn't want it populated..."

Are you keeping in mind what it you are trying to do here? If you make a copy of an attributed block, both the original and the copies have the attributes, even if "last" didn't return just the last single entity, but returned the "last bunch" of stuff, the attributes would still be there, "populated with the same stuff". The originals have the attributes. The copies are COPIES. You said that you wanted to make copies, move them somewhere and put them on a different layer. Given that both the original selection set and the copied set have the attributes, why do you care?

If you now have changed your mind, what do you want?
1)Not copy blocks?
2)Not copy attributed blocks?
3)Re-Insert any blocks that were in the selection set?
4)Edit the attributes of any blocks that were copy/moved/layerchanged?
 
Status
Not open for further replies.
Back
Top