Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using autocad select command in lisp

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
viktors.zilinskis
8943 Views, 7 Replies

Using autocad select command in lisp

Hi!

 

I am trying to create an object selection using ssget function with a filter and then select all objects in autocad with the help of a lisp:

(ssget "_X" '((0 . "0")))(command "select" "p" "")

For some reason no objects become selected in autocad when i run this lisp. If I run the last part manually by typing in the autocad command "select", then press "p" followed by two "enter" keys then I get all objects lying on layer "0" selected in autocad. Then I can for example visually examine which object have been selected and delete them, or change some of their properties etc. I was kind of thinking that i should get the same result using (command "select" "p" "") lisp expression...

7 REPLIES 7
Message 2 of 8
phanaem
in reply to: viktors.zilinskis

DXF code for layers is 8.

(ssget "_X" '((8 . "0")))

 

To hightlight selection, use (command "Pselect" "P" "")

 

Or

(sssetfirst nil (ssget "_X" '((8 . "0"))))

Message 3 of 8
hmsilva
in reply to: viktors.zilinskis

viktors.zilinskis,

try

(ssget "_X" '((8 . "0"))); all objects in layer 0

(command "select" "p" "")

 

Henrique

EESignature

Message 4 of 8
viktors.zilinskis
in reply to: phanaem

Yes, sorry, a typo with the DXF code, it should have been 8. Both variants worked like a charm! I checked autocad help and did not find the PSELECT command though. Is it an undocumented commad and what is the difference between it and SELECT then?

Message 5 of 8
viktors.zilinskis
in reply to: hmsilva

Hi, Henrique! You are right, the DXF code should have been 8, it was a typo from my side.

This part of your answer does not work as I would like to:

(command "select" "p" "")

 Objects become selected while lisp runs, but as soon as it ends they become deselected again. Suggestions provided by phanaem solve the problem  as even when lisp is finished, all relevant objects remain selected in autocad.

Message 6 of 8
Message 7 of 8
hmsilva
in reply to: viktors.zilinskis

viktors.zilinskis wrote,

...Then I can for example visually examine which object have been selected and delete them, or change some of their
properties etc. I was kind of thinking that i should get the same result using (command "select" "p" "") lisp expression...

 

Sorry, I have not read this part of your post,just fix the dxf code for layer name...

 

Henrique

EESignature

Message 8 of 8
tcorey
in reply to: viktors.zilinskis

Fast forward to 2023, I just used the pselect function suggested in post 2 of this thread to solve an issue I was having. I'm not sure what the p means in pselect, but I imagine it to be Persistent. The selected object(s) remain selected even after the lisp ends. That pretty sweet.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost