@Henrik_Lo wrote:
Is it possible use (ssget “X”), to automatic select, in this case is it blocks, I am only using 2
blocks. I like to isolate them and get there entity name, .... I do also know the block names.
....
(defun c:BNA ()
(setq qqq (ssget))
(setq qqqq (ssname qqq 0))
(setq y (entget qqqq))
(setq qqqqa (entget qqqq))
(Setq EName (assoc -1 qqqqa))
);defun
....
Are they two Blocks of different names? If so, and they are not dynamic Blocks, you can find more than one Block name's insertions [however many insertions of them there are] this way:
(setq ss (ssget "_X" '((2 . "BlockName1,BlockName2"))))
You can, if you want, but don't really need to, include the (0 . "INSERT") entry in the filter list -- I think Block insertions are the only drawn things it can find with the 2-code entry [that's always a name, and other things with names are non-drawn things like Layers and Styles, and in any case, not likely to have the same names as your Blocks].
Your code goes to a lot more trouble than necessary. It gets the entity name, pulls the entity data for that, and then gets the entity name again out of that entity data. The entity name is what (ssname) returns to begin with, so to get to it you can skip several of your steps:
(defun c:BNA ()
(setq qqq (ssget))
(setq EName (ssname qqq 0))
);defun
If you mean that you have two Block insertions [whether or not of different Block names], that you want to find and isolate:
(defun c:BNA ()
(setq
qqq (ssget "_X" '((2 . "BlockName1,BlockName2"))))
EName1 (ssname qqq 0)
Ename2 (ssname qqq 1)
)
);defun
Or, if they're two insertions of the same Block name, you can just list that one name in the (ssget) filter, and both will be found.
When as in your original you're after the entity name of a single Block [or anything else] that the User is to select, that can be done without involving (ssget) or (ssname) to pull the entity name from the result:
(setq EName (car (entsel)))
Kent Cooper, AIA