p0peye Posted March 5, 2014 Posted March 5, 2014 Hi all, I am trying to learn a bit of Macro and Lisp, but I am stuck at the beginning. Example: I want to make a shortcut for select previous elements, and try something like "move previous". I tried macro: ^C^C_select;p;; but it's not working. Then I tried LISP: (defun c:sy nil (command "select" "p" " " )(princ)) It does select previous elements, but it stays in "select mode". If I hit enter - elements get de-selected. I tried command (like "move) first, but stil no luck... I tried few more combinations, but you guess - no luck. I tried also with _.PSELECT Also does not work... Any ideas (yes I know that this is trivial to you, but for me it's not ) Thanks, cheers Quote
mostafa badran Posted March 5, 2014 Posted March 5, 2014 try this. (defun c:sy () (command "_.PSELECT" "p")) Quote
BIGAL Posted March 6, 2014 Posted March 6, 2014 So long as you have not done another selection you do not need a seperate defun sy (command "move" "p" "") ; note "" not " " ; also (command "move" "L" "") ; last object created Quote
p0peye Posted March 6, 2014 Author Posted March 6, 2014 (command "move" "p" "") is working, thanks. I am sure I have tried this combo, but ... However - (defun c:sy () (command "select" "p" "")) is NOT working. (When I think again, this is the combo I tried first, and as it was not working, I didn't try at all before mentioned - working - "move" command. I am not sure why "select" combo is not working... try this. (defun c:sy () (command "_.PSELECT" "p")) Command: SY _.PSELECT Unknown command "PSELECT". Press F1 for help. Command: p Unknown command "P". Press F1 for help. Command: nil @MSasu: I'll check the mentioned link, thanks. Quote
mostafa badran Posted March 6, 2014 Posted March 6, 2014 (command "move" "p" "") is working, thanks. I am sure I have tried this combo, but ... However - (defun c:sy () (command "select" "p" "")) is NOT working. (When I think again, this is the combo I tried first, and as it was not working, I didn't try at all before mentioned - working - "move" command. I am not sure why "select" combo is not working... Command: SY _.PSELECT Unknown command "PSELECT". Press F1 for help. Command: p Unknown command "P". Press F1 for help. Command: nil @MSasu: I'll check the mentioned link, thanks. (defun c:sy () (command "PSELECT" "p" "")) Quote
p0peye Posted March 6, 2014 Author Posted March 6, 2014 Thanks for the reply, but it's still "PSELECT Unknown command "PSELECT". Press F1 for help.". A bit odd though: when I type command, it accepts, but when I look in Cmd line history - it shows "select" although I typed "pselect". The same case when I type "._pselect". It accepts, but it is changed to "select". Quote
MSasu Posted March 6, 2014 Posted March 6, 2014 Mostafa Badran, it seems that PSELECT command was discontinued in AutoCAD 2013. On a side note, the "_." prefixes you removed from your code were responsible to ensure calling the English name of the command ("_"), respectivelly ensuring to call its built-in version and not a redefined one ("."). Quote
mostafa badran Posted March 6, 2014 Posted March 6, 2014 Mostafa Badran, it seems that PSELECT command was discontinued in AutoCAD 2013. On a side note, the "_." prefixes you removed from your code were responsible to ensure calling the English name of the command ("_"), respectivelly ensuring to call its built-in version and not a redefined one ("."). Thanks MSasu for clarify to me, but I tested it on 2013,2014 ,it is works fine. Quote
p0peye Posted March 6, 2014 Author Posted March 6, 2014 I am working in AC 2014, and it gives me the error. Strange. Is there another way to assign "select previous" to a shortcut? p.s. - I think MSasu was explaining to me, not to you. And, thank you MSasu for clarifying to me I really didn't know it, although it looks like basic. I don't have time to start from beginning (though I am aware that is the best and easiest way) - I just try to make a simple command - and you see where I got. Quote
cwake Posted March 6, 2014 Posted March 6, 2014 If it came to a choice between using _.SELECT and _.PSELECT I would suggest sticking to _.SELECT. _.PSELECT is associated with the properties palette and appears to only be demand loaded with the palette. So if you don't have the properties palette open it is very likely that _.PSELECT will not be available. To demonstrate from the command line: Command: arx Enter an option [Files/Groups/Commands/CLasses/Services/Load/Unload]: unload Enter ARX/DBX file name to unload: acopm.arx acopm.arx successfully unloaded. Command: pselect Unknown command "PSELECT". Press F1 for help. Command: arx Enter an option [Files/Groups/Commands/CLasses/Services/Load/Unload]: load Enter ARX/DBX file name to load: acopm.arx Command: PSELECT Select objects: Specify opposite corner: 10 found Select objects: Quote
MSasu Posted March 6, 2014 Posted March 6, 2014 After some tests on various workstations (AutoCAD 2012, 2013 and 2014) have learned that said command works on some and not on the other. But now is clear why. Thank you, Cwake! Quote
cwake Posted March 6, 2014 Posted March 6, 2014 Thanks Mircea. No Problem. Is there another way to assign "select previous" to a shortcut? To answer your question p0peye, another way would be to use the lisp expression (ssget "_P") to return the previous selection set. Having said that, I think that by far the most practical approach (and the one that is most consistent with AutoCAD's intention) is what BIGAL said in post #4. The SELECT command creates a selection set that is meant to BE the previous selection set for a subsequent command like move, copy, scale, rotate, etc. To use SELECT with PREVIOUS is actually reversing its intended use. If you already have a PREVIOUS selection set, just apply the command to it. Quote
MSasu Posted March 6, 2014 Posted March 6, 2014 If decide to go with SSGET aproach, then it may worth to take a look to SSSETFIRST function, too. Quote
p0peye Posted March 10, 2014 Author Posted March 10, 2014 Hi all, thanks for the answers. A quick update: (defun c:sy () nil (command "_.PSELECT" "_p" "")(princ)) Works now. Not sure why it wasn't working few days ago - thanks anyway mostafa. I took a look at "A simple selection set LISP gone horribly wrong..." , but I still can't get the logic out of it to reproduce similar code , although I see that it's a very basic level. Maybe in a few months... I have tried the expression ssget "_P", but I am not doing it right. I'll take a look at the links provided on this forum about LISP basics, and try later again. For now, mostafa's code is doing the job. How long - we'll see Cheers p.s. - (defun c:sy () nil (command "SELECT" "_p" "")(princ)) is not working. Quote
BlackBox Posted March 10, 2014 Posted March 10, 2014 p.s. - (defun c:sy () nil (command "SELECT" "_p" "")(princ)) is not working. Instead, consider: (defun c:SY () (sssetfirst nil (ssget "_p")) (princ)) Quote
p0peye Posted March 11, 2014 Author Posted March 11, 2014 Yes, it's working, thank you. I didn't use "sssetfirst" in my experiments - that's why it wasn't working for me. As I said, as soon as I find some free time, I'll take a look at the LISP basics. Thank you all again Quote
BlackBox Posted March 11, 2014 Posted March 11, 2014 Yes, it's working, thank you. I didn't use "sssetfirst" in my experiments - that's why it wasn't working for me. That is kind of you to say, but I merely demonstrated what MSasu suggested. As I said, as soon as I find some free time, I'll take a look at the LISP basics. Thank you all again No worries; we all start somewhere. Cheers Quote
p0peye Posted March 11, 2014 Author Posted March 11, 2014 Yap. MSasu mentioned it (don't get me wrong, I am grateful to him also ) but I didn't know how to put it in the code right. I quickly searched the net for an example, didn't find (or didn't recognize) a useful one, and gave it up for the moment. And then you gave it to me on a golden plate Once again thanks to all for the time spent on this (for you) trivial problem, Cheers 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.