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...
Solved! Go to Solution.
Solved by phanaem. Go to Solution.
DXF code for layers is 8.
(ssget "_X" '((8 . "0")))
To hightlight selection, use (command "Pselect" "P" "")
Or
(sssetfirst nil (ssget "_X" '((8 . "0"))))
viktors.zilinskis,
try
(ssget "_X" '((8 . "0"))); all objects in layer 0
(command "select" "p" "")
Henrique
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?
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.
Ok, found some kind of "explanations" here:
http://www.nyacad.com/PSelect.htm
http://forums.autodesk.com/t5/Drafting-Techniques/Pselect/td-p/64466
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
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.