Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
(defun c:SG1 ()
(setq ss (ssget "X" '((8 . "123"))))
)
i tried to create this code from internet but it is not working
Solved! Go to Solution.
(defun c:SG1 ()
(setq ss (ssget "X" '((8 . "123"))))
)
i tried to create this code from internet but it is not working
Solved! Go to Solution.
How do you know it's not working? You can determine whether it found anything with
(sslength ss)
which will tell you how many things it found. Also, if it found things, it will report something like this when you use the command:
Command: SG1
<Selection set: 5d>
That would report nil if it didn't find anything.
All your code has been asked to do is put them in a selection set, which by itself will not "show" in any way in the drawing. If you want them to then be selected/highlighted/gripped for you, that's another operation:
(sssetfirst nil ss)
C:SG1 ( / sel1)
(setq sel1 (ssget "_X" '((8 . "123"))))
(sssetfirst nil sel1)
(princ)
)
this code works for me
Consider:
(defun C:SG1 (/ sel1)
(if (setq sel1 (ssget "_X" '((8 . "123"))))
(sssetfirst nil sel1); then
(prompt "\nNo top-level object(s) found on Layer 123."); else
); if
(princ)
)
Otherwise, if there's nothing on that Layer, your code will return:
(nil nil)
which could be confusing to Users.