@Anonymous wrote:
....
What I want to do is create a button that'll move a given object 150 units to the left. So I select a rectangle on my drawing and then press the button three times, then I want the rectangle to move 450 units to the left.
....
Welcome to these Forums!
[That's not a Script, by the way -- "SCRIPT" has a specific and different meaning in AutoCAD. It's a "command macro." Nor is it a "Lisp command" as in the Subject line, but I can imagine that's a description of what you are assuming might be needed, not what you're starting with.]
You don't need PSELECT as a command anyway. You can just select things ahead of time if you have PICKFIRST turned on. In that situation, the problem with @ВeekeeCZ's suggestion is that if you give "P" as an option to a Move command that was called up with pre-selected objects, you are responding to the base-point-or-displacement prompt, for which P is not a valid option, and you get a "Point or option keyword required" error message, and it goes back to the prompt.
This works [in limited testing] if you start with a pre-selection and then hit the macro button multiple times [yes, even in a macro, in which some AutoLisp functions can be used -- I'll assume from the Subject line that you're not using Acad LT ]:
(if (ssget "_I") (command "_.move" "-150,0" "") (command "_.move" "_p" "" "-150,0" ""))
The (ssget "_I") is checking whether there's an Implied selection [your pre-selected object(s)], which will be true the first time you hit the button, so it will just give the displacement. On subsequent picks, the pre-selection won't still be in effect, but the same thing(s) will be the "Previous" selection, so it will use that.
If there is no pre-selection when you first pick the macro button, it will of course Move whatever qualifies as "Previous" [if anything], as will BeekeeCZ's suggestion, so it does need you to pick things before the first use.
Kent Cooper, AIA