Hello!
I'm currently using Plant 3D 2022.1.2 (P3D_S051.1521), built on S.173.0.0 AutoCAD 2022.1.3.
All relevant updates have been installed.
I'm currently trying to write a simple lisp function that will allow me to select all Plant 3D objects within modelspace.
I've got what seems to be the correct code to do so, but whenever I run the code it fails to select the items in question.
I've tried (2) different methods and from what I've seen online, both should work but neither do.
"V1"
(defun c:SAD
(ssget "X" '((0 . "ACPP")))
(command "select" "p" "")
)
----------------------------------------
"V2"
(defun c:SAD
(ssget "X" '((0 . "ACPP")))
(setq ss1 (ssget "P"))
)
I've also been getting a consistent error when loading the code into P3D, which states ; error: syntax error
This code was written and formatted in Visual Studio Code, UTF-8 Encoding.
I've tried re-encoding the file into ANSI in Wordpad++, windows1252, iso88591, iso88593, and iso885915 in Vsc, but none of them seem to fix this.
Can anyone lend me a hand in determining why the above code isn't performing as intended, and why I continue to have the syntax error?
Much appreciated.
Solved! Go to Solution.
Solved by matt.worland. Go to Solution.
Hello, I looks like your missing the asterisk * in your search. It should be:
(ssget "x" '((0 . "ACPP*")))
@matt.worland,
Thank you for your reply!
In the time since I posted this, I did notice some errors with what I had written.
here is the current code:
(defun c:sad ()
(setq ss1 (ssget "X" '((0 . "ACPP*"))))
(setq ss2 (ssget "P"))
)
Now the code does create a new selection set and names it, but the 3rd line doesn't seem to be running as intended.
It refuses to set the previous selection set as active.
Any ideas?
I believe the syntax error could be the missing parens after your defun
(defun c:SAD ()
Got it, that's been added.
Am I missing something that's keeping the lisp from running the 3rd line to select the previous selection set?
Or do I have the code structured incorrectly that you can tell?
SSGET allows you to store a colleciton of entities in a variable. It won't select them visually on the screen, but it will allow you to iterate through them.
Once you have your collection you can use a vlax-for, like this
(setq ss1(ssget "X" '((0 . "ACPP*"))))
(vlax-for objCurrent (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
;Do your stuff here
; you could even highlight them here
(vla-Highlight objCurrent :vlax-True)
)
This is exactly what I was looking for, and resolves the issue.
Thank you so much for your input and time!
Can't find what you're looking for? Ask the community or share your knowledge.