Lkoster08 Posted May 4, 2017 Posted May 4, 2017 Hello all! First time posting here, and I need help. I am just delving into lisps and this quick one I wrote seems to be broken. ;;SELECT ALL (defun c:SA () (command "_.select" "_all") (princ) ) It selects all items in my drawing as asked, but then I can't enter another command after it (no way to move/copy/delete-etc.). What am I missing and if it's not to much please fill me in on why it's not working. Thank you! Quote
SLW210 Posted May 4, 2017 Posted May 4, 2017 Please read the Code Posting Guidelines and edit your Code to be included in Code Tags.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
Lkoster08 Posted May 4, 2017 Author Posted May 4, 2017 ;;SELECT ALL (defun c:SA () (command "_.select" "_all") (princ) ) Quote
Lkoster08 Posted May 4, 2017 Author Posted May 4, 2017 Sorry about that and thank your for the head's up! Quote
BKT Posted May 5, 2017 Posted May 5, 2017 (edited) The select command allows you to use "previous" in other commands like move, copy, etc., by entering the letter "p" (no quotes) when asked for the selection. In your example, you would need to add a double quote to end the command: (command "_.select" "_all" [color=red]""[/color]) Or, if you want to add say, the move command to your code, you could do something like this: (command "_.select" "_all" "" ".move" "p" "" pause pause) Edited May 5, 2017 by BKT Quote
Lkoster08 Posted May 5, 2017 Author Posted May 5, 2017 It seems to not select anything now or perhaps it is selecting all and then finishes the command and thus I cannot manipulate them. ;;SELECT ALL (defun c:SA () (command "_.select" "_all" "") (princ) ) This was after I updated from your input. Quote
BKT Posted May 5, 2017 Posted May 5, 2017 Maybe I wasn't clear - the SELECT command just creates a selection set. Once that's done, you can manipulate them, but you'll need to call whatever command you want after that. In the second piece of code I posted above as an example, the MOVE command is combined with SELECT so you could move all entities by picking points. If you wanted to do a MOVE, for example, you could also use a simple line of code like this: (command "._move" "ALL" "" pause pause) If you want to manipulate the entities selected you'll need to add more to the code. Quote
Lkoster08 Posted May 5, 2017 Author Posted May 5, 2017 If I type in the normal commands "Select" and "All" and hit enter to confirm my selection, I can then tell it what I want to do with my selection (such as move/copy/delete-etc.). It does appear I am out of the select command, but they are all selected and ready for the appropriate noun-verb command prompt to do something else. How can I make my lisp do essentially "select" "all" "enter" - to have everything selected to then be modified by whatever command I choose to do next? Quote
BKT Posted May 5, 2017 Posted May 5, 2017 After you run your posted code, everything is in a selection set. Just do a MOVE (or whatever) command and enter P for previous selection and the set you created will be selected. Quote
tombu Posted May 5, 2017 Posted May 5, 2017 Try: ;;SELECT ALL (defun c:SA () (setq ss(ssget "X")) (sssetfirst nil ss) (princ) ) Quote
Lkoster08 Posted May 5, 2017 Author Posted May 5, 2017 I think I understand now what is happening with the code I was using. The code you provided tombu works just like I wanted it to, but now I wonder what is different about your code than mine as far as how it works? Quote
Lkoster08 Posted May 5, 2017 Author Posted May 5, 2017 Why is this LISP necessary? This is more for my understanding of how basic lisps work more than anything else. I have quite a few I've searched for and use daily, and trying to write my own based on those codes is very rough. Quote
tombu Posted May 5, 2017 Posted May 5, 2017 I think I understand now what is happening with the code I was using. The code you provided tombu works just like I wanted it to, but now I wonder what is different about your code than mine as far as how it works? There's a lot of selection options available in lisp, see online help AutoLISP functions: Check out all the options for SSGET and all the GETXXXXXXXX functions. As a rule I'd avoid using the COMMAND function unless you have to. Quote
BIGAL Posted May 6, 2017 Posted May 6, 2017 Another example ;;move ALL (defun c:mall( / ss) (setq ss(ssget "X")) (command "Move" ss "" (getpoint)(getpoint)) (princ) ) 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.