创建选择集后,可以向其添加图元或从中选择移除图元。ssaddssdel 可以使用该函数创建新的选择集或向现有选择集添加实体。以下示例代码创建一个选择集,该选择集包括当前图形中的第一个和最后一个图元(和):ssaddentnextentlast (setq fname (entnext)) ; Gets first entity in the drawing. (setq lname (entlast)) ; Gets last entity in the drawing. (if (not fname) (princ "\nNo entities in drawing. ") (progn (setq ourset (ssadd fname)) ; Creates a selection set ; of the first entity. (ssadd lname ourset) ; Adds the last entity to ; the selection set. ) ) 即使数据库中只有一个实体,该示例也能正常运行(在这种情况下,两者将其参数设置为相同的实体名称)。Ifis 传递了选择集中已有实体的名称,它会忽略请求并且不报告错误。entnextentlastssadd 以下示例代码从上一示例中创建的选择集中删除第一个实体: (ssdel fname ourset) 如果图形中有多个图元(即,ifandare 不相等),则选择集仅包含图形中的最后一个图元。fnamelnameoursetlname 该函数返回选择集中的图元数,并测试特定图元是否为选择集的成员。最后,该函数使用选择集中特定实体的名称返回该集的索引(选择集中的实体从 0 开始编号)。sslengthssmembssname 以下示例代码演示对以下内容的调用:ssname (setq sset (ssget)) ; Prompts the user to create ; a selection set. (setq ent1 (ssname sset 0)) ; Gets the name of the first ; entity in sset. (setq ent4 (ssname sset 3)) ; Gets the name of the fourth ; entity in sset. (if (not ent4) (princ "\nNeed to select at least four entities. ") ) (setq ilast (sslength sset)) ; Finds index of the last ; entity in sset. ; Gets the name of the last ; entity in sset. (setq lastent (ssname sset (1- ilast))) 无论如何将实体添加到选择集,该集都不会包含重复的实体。如果多次添加同一实体,则忽略后面的添加。因此,准确返回指定选择集中不同图元的数量。sslength |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )
GMT+8, 2024-5-19 15:52
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.