嗨,卡斯滕,
像这样的怎么样?
- ;;----------------=={ Add Objects to Block }==----------------;;
- ;; ;;
- ;; Adds all objects in the provided SelectionSet to the ;;
- ;; definition of the specified block. ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, June 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; block - Entity name of reference insert ;;
- ;; ss - SelectionSet of objects to add to definition ;;
- ;;------------------------------------------------------------;;
- (defun LM:AddObjectstoBlock ( block ss / ObjLst org doc vector )
- ;; © Lee Mac 2010
- (vl-load-com)
- (setq ObjLst (LM:ss->vla ss) org (vlax-3D-point '(0. 0. 0.)))
- (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
-
- (setq vector
- (vlax-3D-point
- (mapcar '- (cdr (assoc 10 (entget block)))
- (cdr
- (assoc 10
- (entget
- (tblobjname "BLOCK"
- (cdr (assoc 2 (entget block)))
- )
- )
- )
- )
- )
- )
- )
- (mapcar '(lambda ( obj ) (vla-move obj vector org)) ObjLst)
- (vla-CopyObjects (vla-get-ActiveDocument (vlax-get-acad-object))
- (LM:ObjectVariant ObjLst)
- (vla-item (vla-get-Blocks doc)
- (LM:GetBlockName (vlax-ename->vla-object block))
- )
- )
- (LM:ApplyFootoSS (lambda ( x ) (entdel x)) ss)
- (vla-regen doc acAllViewports)
- )
- ;;------------------=={ Safearray Variant }==-----------------;;
- ;; ;;
- ;; Creates a populated Safearray Variant of a specified ;;
- ;; data type ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, June 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, June 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, June 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 ;;
- ;;------------------------------------------------------------;;
|