也许使用匿名组?
- (defun c:grp ( / l )
- (vl-load-com)
- ;; © Lee Mac 2010
- (if (setq l (LM:SS->VLA (ssget)))
- (vla-AppendItems
- (vla-Add
- (vla-get-Groups
- (vla-get-ActiveDocument
- (vlax-get-acad-object)
- )
- )
- "*"
- )
- (LM:ObjectVariant l)
- )
- )
- (princ)
- )
- ;;------------------=={ Safearray Variant }==-----------------;;
- ;; ;;
- ;; Creates a populated Safearray Variant of a specified ;;
- ;; data type ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; datatype - variant type enum (eg vlax-vbDouble) ;;
- ;; data - list of static type data ;;
- ;;------------------------------------------------------------;;
- ;; Returns: VLA Variant Object of type specified ;;
- ;;------------------------------------------------------------;;
- (defun LM:SafearrayVariant ( datatype data )
- ;; © Lee Mac 2010
- (vlax-make-variant
- (vlax-safearray-fill
- (vlax-make-safearray datatype
- (cons 0 (1- (length data)))
- )
- data
- )
- )
- )
- ;;-------------------=={ Object Variant }==-------------------;;
- ;; ;;
- ;; Creates a populated Object Variant ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; lst - list of VLA Objects to populate the Variant. ;;
- ;;------------------------------------------------------------;;
- ;; Returns: VLA Object Variant ;;
- ;;------------------------------------------------------------;;
- (defun LM:ObjectVariant ( lst )
- ;; © Lee Mac 2010
- (LM:SafearrayVariant vlax-vbobject lst)
- )
- ;;-----------------=={ SelectionSet -> VLA }==----------------;;
- ;; ;;
- ;; Converts a SelectionSet to a list of VLA Objects ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; ss - Valid SelectionSet (Pickset) ;;
- ;;------------------------------------------------------------;;
- ;; Returns: List of VLA Objects ;;
- ;;------------------------------------------------------------;;
- (defun LM:ss->vla ( ss )
- ;; © Lee Mac 2010
- (if ss
- (
- (lambda ( i / e l )
- (while (setq e (ssname ss (setq i (1+ i))))
- (setq l (cons (vlax-ename->vla-object e) l))
- )
- l
- )
- -1
- )
- )
- )
|