Jump to content

Recommended Posts

Posted

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!

Posted
;;SELECT ALL
(defun c:SA ()
(command "_.select" "_all")
(princ)
)

Posted

Sorry about that and thank your for the head's up!

Posted (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 by BKT
Posted

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.

Posted

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.

Posted

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?

Posted

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.

Posted

Try:

;;SELECT ALL
(defun c:SA ()
 (setq ss(ssget "X"))
 (sssetfirst nil ss)
 (princ)
)

Posted

Why is this LISP necessary?

Posted

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?

Posted
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.

Posted
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.

Posted

Another example

 

;;move ALL
(defun c:mall( / ss)
 (setq ss(ssget "X"))
 (command "Move" ss "" (getpoint)(getpoint))
 (princ)
)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...