Help with Select Previous

Help with Select Previous

nrz13
Advisor Advisor
4,411 Views
20 Replies
Message 1 of 21

Help with Select Previous

nrz13
Advisor
Advisor

I'm trying to automate selecting all the previous objects.

If I type SELECT and enter P, this works.  But when I put that into a LISP, it doesn't keep the selection.  What am I doing wrong?  Thanks

(DEFUN C:SEL ()(COMMAND "SELECT" "P")(PRINC))


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Accepted solutions (2)
4,412 Views
20 Replies
Replies (20)
Message 2 of 21

ВeekeeCZ
Consultant
Consultant
Accepted solution
Try pselect.
0 Likes
Message 3 of 21

Ranjit_Singh
Advisor
Advisor
Accepted solution

Maybe use ssget

(sssetfirst () (ssget "_p"))
Message 4 of 21

nrz13
Advisor
Advisor

That worked.  Thanks, BeekeeCZ!  I wasn't familiar with PSELECT.

Solution:
(DEFUN C:SEL ()(COMMAND "PSELECT" "P")(PRINC))


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 5 of 21

john.uhden
Mentor
Mentor

It is upsetting to see how you are so underpowered both at work and at home.  Smiley Sad

Your dual 29" monitors must eat up all your desk space too.  😕

You should consider hooking up to your 70" LED TV with an HDMI-AWD cable.

John F. Uhden

0 Likes
Message 6 of 21

nrz13
Advisor
Advisor

They're 30" monitors, not 29".  Smiley Wink

And just think, all that extra power so I can run this LISP .000000001 times faster!


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 7 of 21

john.uhden
Mentor
Mentor
I am so thankful you have a sense of humor. There are a number here who
don't appreciate mine.

BTW, though I have immense respect and appreciation for BeekeeCZ, I like
Ranjit's answer better.

John F. Uhden

0 Likes
Message 8 of 21

nrz13
Advisor
Advisor

What is the advantage of using ssget over pselect?


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 9 of 21

john.uhden
Mentor
Mentor
Some of us are just afflicted with purism. I like to avoid using the
command function if I can help it. If Autodesk changes or drops the
command, then my code becomes obsolete. Plus, functions like ssget return
a selection set, something I can work on directly without any other code to
convert it or such, and there's all that filtering you can add. In many
cases I prefer to use entmake or entmakex instead of calling a command to
create an entity.

John F. Uhden

0 Likes
Message 10 of 21

nrz13
Advisor
Advisor

Thanks for the additional info. My LISP knowledge is very basic, so I think pselect will work fine for me.  Autodesk puts those commands in there for people like me who don't really know what they're doing.

If they ever change it, and I miss the release documentation on it, I'll come back here and bug you and you can remind me how wrong I was.  Smiley Wink


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
Message 11 of 21

john.uhden
Mentor
Mentor
You're doing just fine. Whatever works for you is what counts.

John F. Uhden

0 Likes
Message 12 of 21

ВeekeeCZ
Consultant
Consultant

@nrz13 wrote:

... My LISP knowledge is very basic, so I think pselect will work fine for me.  Autodesk puts those commands in there for people like me who don't really know what they're doing...


Well said. Glad that someone shares the same thinking. 

 

I have and use hundreds of these kind of simple shortcuts, the one you've written now is between them as well.

 

(defun c:SS () 				;Pre-select previous selection set
  (command "_.PSELECT" "_P" "")
  (princ)
)

The only difference is, that your routine leave the selection open to possibly add other object to the selection or you need to hit enter to close it, but my not. Not sure if that behavior was intentional from you -- you may add the red quotes in case it was not.

 

Enjoy your couple of secs per a year you spared...

Message 13 of 21

cadffm
Consultant
Consultant

And what is when command PSELECT is not available?

 

 

If someone use undocumented/hidden command "PSELECT" (menumacro script command sendcommands..), make sure that pselect is available.

 

for your S::STARTUP

(if (not(member "acopm.arx" (arx))) (arxload "acopm.arx")) ; if acopm is not available you have bigger problems with your profile.

Sebastian

0 Likes
Message 14 of 21

ВeekeeCZ
Consultant
Consultant

@cadffm wrote:

And what is when command PSELECT is not available?

 

...

Hm, when I open a new document, type in (command "PSELECT"), it works. So when might possibly happen the situation that the PSELECT is not loaded?

0 Likes
Message 15 of 21

cadffm
Consultant
Consultant
If you start acad with a profile/workspace in that the propertie palette is set to OFF.

The acopm.arx is load by this palette.

Sebastian

0 Likes
Message 16 of 21

ВeekeeCZ
Consultant
Consultant

@cadffm wrote:
If you start acad with a profile/workspace in that the propertie palette is set to OFF.

The acopm.arx is load by this palette.

Still unable to confirm that. Using C3D 2016 as Autocad, ACAD profile, in CUI is the current profile set the "show properties" palette option to NO. Yet, I can run PSELECT without need to load it. 

 

@nrz13

Another way to fix the SELECT command behavior under LISP -- and possibly cleaner way to do that than using "undocumented" command -- is to use the predecessor (initcommandversion) which forces the LISP version of certain command to act as same as autocad's version.

 

(DEFUN C:SEL () (initcommandversion) (COMMAND "PSELECT" "P")(PRINC))
0 Likes
Message 17 of 21

nrz13
Advisor
Advisor

Thanks, BeekeeCZ.  I did have the end quotations in there when I first set it up using SELECT, but when that wasn't working I had taken them out.  They're back in there now.

And it's already saved me a hassle programming this in because I was doing a lot of repetitive stuff the other day going through a number of drawings.  I used this every other command.  Also, I would use SS for the keyboard shortcut, but that's already set to SPLINE, which I normally use more often.  I'm running out of 2- and 3-key combinations I can enter with my left hand only that make any sense.


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 18 of 21

cadffm
Consultant
Consultant

@ВeekeeCZ

Yes, C3D is not equal to AutoCAD (you start your Product as "C3D" and not as "ACAD" (startup switch /product ),

only starting with a Profile named "AutoCAD" is not the same) C3D loads "acopm.arx" for others things.

 

Another example for the difference between ACAD and "C3D as Acad" is,

C3D will every time add the Supportpath "C:\program files\autodesk\autocad 2017\map\bin\fdo" to your Profile

and some things more.

 

 

 

Unload the arx and you will see. In plain AutoCAD the arx is not loaded (when properties palette is off).

 

 

Sebastian

Message 19 of 21

nrz13
Advisor
Advisor

Thanks for that point, @cadffm.  I always have the Properties palette open on this computer, so I had not noticed that but, indeed, the command fails to run if the Properties palette is not open.  Using @Ranjit_Singh's solution instead.

Solution:
(defun c:sel ()(sssetfirst () (ssget "_p"))(princ))


Work:  AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-8700K, 64GB RAM, Samsung 960 Pro SSD, AMD Radeon Pro WX 5100, 3 Dell Monitors (3840x2160)
Home: AutoCAD 2022.1.3, Windows 10 Pro v22H2 64-bit, Intel Core i7-11700, 64GB RAM, Samsung 980 Pro SSD, NVIDIA Quadro P2200, Dell Monitor (3840x2160)
0 Likes
Message 20 of 21

cadffm
Consultant
Consultant
And back to the first post:


"If I type SELECT and enter P, this works. "

Only if PickAdd is set to 2, normally (in the past when pickadd is not set to 2) the SELECT command only create a selectionset.



"But when I put that into a LISP, it doesn't keep the selection. "
Because Autocad know the command start in automatism (script macro command) and then some commands run different to "by hand".

Layer start command -Layer (commandline version of Layer)
or ignores pickadd=2 and work like pickadd=1
and some thingd more..

Sebastian

0 Likes