SelectionSet to List

Function Syntax (LM:ss->ent <ss>) / (LM:ss->vla <ss>)
Current Version 1.0
Arguments
Symbol Type Description
ss SelectionSet SelectionSet to convert to a list of entities or objects.
Returns
Type Description
List List of Entity Names or VLA-Objects in the supplied SelectionSet.

Program Description

Here I offer two subfunctions to convert a SelectionSet into a list of entity names or VLA-Objects. Each requires a single SelectionSet argument and will test for the validity of such argument.

SelectionSet to Entities

Select all
;;--------------=={ SelectionSet -> Entities }==--------------;;
;;                                                            ;;
;;  Converts a SelectionSet to a list of Entities             ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright  2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  ss - Valid SelectionSet (Pickset)                         ;;
;;------------------------------------------------------------;;
;;  Returns:  List of Entity names, else nil                  ;;
;;------------------------------------------------------------;;

(defun LM:ss->ent ( ss / i l )
    (if ss
        (repeat (setq i (sslength ss))
            (setq l (cons (ssname ss (setq i (1- i))) l))
        )
    )
)

SelectionSet to VLA-Objects

Select all
;;------------=={ SelectionSet -> VLA Objects }==-------------;;
;;                                                            ;;
;;  Converts a SelectionSet to a list of VLA Objects          ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright  2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  ss - Valid SelectionSet (Pickset)                         ;;
;;------------------------------------------------------------;;
;;  Returns:  List of VLA Objects, else nil                   ;;
;;------------------------------------------------------------;;

(defun LM:ss->vla ( ss / i l )
    (if ss
        (repeat (setq i (sslength ss))
            (setq l (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) l))
        )
    )
)

textsize

increase · reset · decrease

Designed & Created by Lee Mac © 2010