AutoLISP 101 - Entity Names - Discussion
Entity Names
Entities are necessary for manipulating data in drawing files.
All graphic items (lines, circles, etc...) are entities.
Useful Entity Functions
Code:
(entlast)
will return the last graphic entity in a drawing.
Code:
(handent "1C7")
will return the entity associated with the unique hexadecimal identifier called a handle.
Code:
(entsel)
will prompt the user to select an object and return a list with two items including the entityname the point selected.
So...
Code:
(car (entsel))
will return a selected objects entity name (car returns the first item in a list)
So to get and store an entityname you use the setq expression.
Code:
(setq entSelection (car (entsel "\nSelect One Item: ")))
the entsel expression allows for a prompt ("\n" is a carriage return)
The default prompt is "Select objects:"
There is also
Code:
(setq entSelectionNested (car (nentsel "\nSelect nested item: ")))
Which allows the user to select items nested inside other items (like blocks)
Try it and comment to the discussion thread.
Re: AutoLISP 101 - Entity Names - Discussion
You can use also (ssname)!
((lambda ( / js n)
(setq js (ssget))
(cond
(js
(repeat (setq n (sslength js))
(print (ssname js (setq n (1- n))))
)
)
)
(prin1)
))
Re: AutoLISP 101 - Entity Names - Discussion
You are absolutely right.
I have not got to selection sets yet...
It is on the list.
I just wanted to make each of these posts relatively short.
Entity Lists, Tables and Selection are up soon.
P=